| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
class Doctrine_Ticket_929_TestCase extends Doctrine_UnitTestCase |
|---|
| 33 |
{ |
|---|
| 34 |
public function prepareData(){ |
|---|
| 35 |
$oPerson = new T929_Person; |
|---|
| 36 |
$oPerson->name = 'Jonathan'; |
|---|
| 37 |
$oPerson->Country->code = 'us'; |
|---|
| 38 |
$oPerson->Country->Translation['fr']->name = 'Etats Unis'; |
|---|
| 39 |
$oPerson->Country->Translation['en']->name = 'United states'; |
|---|
| 40 |
$oPerson->save(); |
|---|
| 41 |
|
|---|
| 42 |
parent :: prepareData(); |
|---|
| 43 |
} |
|---|
| 44 |
|
|---|
| 45 |
public function prepareTables(){ |
|---|
| 46 |
$this->tables = array(); |
|---|
| 47 |
$this->tables[] = 'T929_Person'; |
|---|
| 48 |
$this->tables[] = 'T929_Country'; |
|---|
| 49 |
$this->tables[] = 'T929_JobPosition'; |
|---|
| 50 |
$this->tables[] = 'T929_JobCategory'; |
|---|
| 51 |
|
|---|
| 52 |
parent :: prepareTables(); |
|---|
| 53 |
} |
|---|
| 54 |
|
|---|
| 55 |
public function testTicket(){ |
|---|
| 56 |
try { |
|---|
| 57 |
$q = new Doctrine_Query(); |
|---|
| 58 |
$r = $q |
|---|
| 59 |
->from('T929_Person P') |
|---|
| 60 |
->leftJoin('P.Country Ct') |
|---|
| 61 |
->leftJoin('Ct.Translation T1 WITH T1.lang = ?', 'fr') |
|---|
| 62 |
->leftJoin('P.JobPositions J') |
|---|
| 63 |
->leftJoin('J.Category C') |
|---|
| 64 |
->leftJoin('C.Translation T2 WITH T2.lang = ?', 'fr') |
|---|
| 65 |
->where('P.name = ?', 'Jonathan') |
|---|
| 66 |
->fetchOne(); |
|---|
| 67 |
} catch(Exception $e){ |
|---|
| 68 |
$this->fail($e->getMessage()); |
|---|
| 69 |
} |
|---|
| 70 |
} |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
class T929_Person extends Doctrine_Record |
|---|
| 74 |
{ |
|---|
| 75 |
public function setTableDefinition() { |
|---|
| 76 |
$this->setTableName('T929_person'); |
|---|
| 77 |
$this->hasColumn('country_id', 'integer'); |
|---|
| 78 |
$this->hasColumn('name', 'string', 200); |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
public function setUp() { |
|---|
| 82 |
parent :: setUp(); |
|---|
| 83 |
$this->hasOne('T929_Country as Country', array( |
|---|
| 84 |
'local' => 'country_id', |
|---|
| 85 |
'foreign' => 'id', |
|---|
| 86 |
'onDelete' => 'CASCADE' |
|---|
| 87 |
)); |
|---|
| 88 |
|
|---|
| 89 |
$this->hasMany('T929_JobPosition as JobPositions', array( |
|---|
| 90 |
'local' => 'id', |
|---|
| 91 |
'foreign' => 'person_id', |
|---|
| 92 |
'onDelete' => 'CASCADE' |
|---|
| 93 |
)); |
|---|
| 94 |
} |
|---|
| 95 |
} |
|---|
| 96 |
|
|---|
| 97 |
class T929_Country extends Doctrine_Record { |
|---|
| 98 |
|
|---|
| 99 |
public function setTableDefinition() |
|---|
| 100 |
{ |
|---|
| 101 |
$this->setTableName('T929_country'); |
|---|
| 102 |
$this->hasColumn('name', 'string', 200); |
|---|
| 103 |
$this->hasColumn('code', 'string', 200); |
|---|
| 104 |
} |
|---|
| 105 |
|
|---|
| 106 |
public function setUp() { |
|---|
| 107 |
parent :: setUp(); |
|---|
| 108 |
$this->hasMany('T929_Person as Persons', array( |
|---|
| 109 |
'local' => 'id', |
|---|
| 110 |
'foreign' => 'country_id', |
|---|
| 111 |
'onDelete' => 'CASCADE' |
|---|
| 112 |
)); |
|---|
| 113 |
|
|---|
| 114 |
$this->actAs('I18n', array('fields' => array('name'))); |
|---|
| 115 |
} |
|---|
| 116 |
} |
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
class T929_JobPosition extends Doctrine_Record |
|---|
| 121 |
{ |
|---|
| 122 |
public function setTableDefinition(){ |
|---|
| 123 |
$this->setTableName('T929_address'); |
|---|
| 124 |
$this->hasColumn('name', 'string', 200); |
|---|
| 125 |
$this->hasColumn('person_id', 'integer'); |
|---|
| 126 |
$this->hasColumn('job_category_id', 'integer'); |
|---|
| 127 |
} |
|---|
| 128 |
|
|---|
| 129 |
public function setUp() { |
|---|
| 130 |
parent :: setUp(); |
|---|
| 131 |
$this->hasOne('T929_Person as Person', array( |
|---|
| 132 |
'local' => 'person_id', |
|---|
| 133 |
'foreign' => 'id', |
|---|
| 134 |
'onDelete' => 'CASCADE' |
|---|
| 135 |
)); |
|---|
| 136 |
|
|---|
| 137 |
$this->hasOne('T929_JobCategory as Category', array( |
|---|
| 138 |
'local' => 'job_category_id', |
|---|
| 139 |
'foreign' => 'id', |
|---|
| 140 |
'onDelete' => 'CASCADE' |
|---|
| 141 |
)); |
|---|
| 142 |
} |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
class T929_JobCategory extends Doctrine_Record |
|---|
| 146 |
{ |
|---|
| 147 |
public function setTableDefinition() { |
|---|
| 148 |
$this->setTableName('job_category'); |
|---|
| 149 |
$this->hasColumn('code', 'integer', 4); |
|---|
| 150 |
$this->hasColumn('name', 'string', 200); |
|---|
| 151 |
} |
|---|
| 152 |
|
|---|
| 153 |
public function setUp() { |
|---|
| 154 |
parent :: setUp(); |
|---|
| 155 |
$this->hasMany('T929_JobPosition as Positions', array( |
|---|
| 156 |
'local' => 'id', |
|---|
| 157 |
'foreign' => 'job_category_id', |
|---|
| 158 |
'onDelete' => 'CASCADE' |
|---|
| 159 |
)); |
|---|
| 160 |
|
|---|
| 161 |
$this->actAs('I18n', array('fields' => array('name'))); |
|---|
| 162 |
} |
|---|
| 163 |
} |
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|