|
@@ 2944-2980 (lines=37) @@
|
| 2941 |
|
* |
| 2942 |
|
* @return void |
| 2943 |
|
*/ |
| 2944 |
|
public function testSaveAllHabtmWithExtraJoinTableFields() { |
| 2945 |
|
$this->loadFixtures('Something', 'SomethingElse', 'JoinThing'); |
| 2946 |
|
|
| 2947 |
|
$data = array( |
| 2948 |
|
'Something' => array( |
| 2949 |
|
'id' => 4, |
| 2950 |
|
'title' => 'Extra Fields', |
| 2951 |
|
'body' => 'Extra Fields Body', |
| 2952 |
|
'published' => '1' |
| 2953 |
|
), |
| 2954 |
|
'SomethingElse' => array( |
| 2955 |
|
array('something_else_id' => 1, 'doomed' => '1'), |
| 2956 |
|
array('something_else_id' => 2, 'doomed' => '0'), |
| 2957 |
|
array('something_else_id' => 3, 'doomed' => '1') |
| 2958 |
|
) |
| 2959 |
|
); |
| 2960 |
|
|
| 2961 |
|
$Something = new Something(); |
| 2962 |
|
$result = $Something->saveAll($data); |
| 2963 |
|
$this->assertFalse(empty($result)); |
| 2964 |
|
$result = $Something->read(); |
| 2965 |
|
|
| 2966 |
|
$this->assertEquals(3, count($result['SomethingElse'])); |
| 2967 |
|
$this->assertTrue(Set::matches('/Something[id=4]', $result)); |
| 2968 |
|
|
| 2969 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=1]', $result)); |
| 2970 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=1]/JoinThing[something_else_id=1]', $result)); |
| 2971 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=1]/JoinThing[doomed=1]', $result)); |
| 2972 |
|
|
| 2973 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=2]', $result)); |
| 2974 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=2]/JoinThing[something_else_id=2]', $result)); |
| 2975 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=2]/JoinThing[doomed=0]', $result)); |
| 2976 |
|
|
| 2977 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=3]', $result)); |
| 2978 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=3]/JoinThing[something_else_id=3]', $result)); |
| 2979 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=3]/JoinThing[doomed=1]', $result)); |
| 2980 |
|
} |
| 2981 |
|
|
| 2982 |
|
/** |
| 2983 |
|
* testSaveAllHasOne method |
|
@@ 5150-5186 (lines=37) @@
|
| 5147 |
|
* |
| 5148 |
|
* @return void |
| 5149 |
|
*/ |
| 5150 |
|
public function testSaveAssociatedHabtmWithExtraJoinTableFields() { |
| 5151 |
|
$this->loadFixtures('Something', 'SomethingElse', 'JoinThing'); |
| 5152 |
|
|
| 5153 |
|
$data = array( |
| 5154 |
|
'Something' => array( |
| 5155 |
|
'id' => 4, |
| 5156 |
|
'title' => 'Extra Fields', |
| 5157 |
|
'body' => 'Extra Fields Body', |
| 5158 |
|
'published' => '1' |
| 5159 |
|
), |
| 5160 |
|
'SomethingElse' => array( |
| 5161 |
|
array('something_else_id' => 1, 'doomed' => '1'), |
| 5162 |
|
array('something_else_id' => 2, 'doomed' => '0'), |
| 5163 |
|
array('something_else_id' => 3, 'doomed' => '1') |
| 5164 |
|
) |
| 5165 |
|
); |
| 5166 |
|
|
| 5167 |
|
$Something = new Something(); |
| 5168 |
|
$result = $Something->saveAssociated($data); |
| 5169 |
|
$this->assertFalse(empty($result)); |
| 5170 |
|
$result = $Something->read(); |
| 5171 |
|
|
| 5172 |
|
$this->assertEquals(3, count($result['SomethingElse'])); |
| 5173 |
|
$this->assertTrue(Set::matches('/Something[id=4]', $result)); |
| 5174 |
|
|
| 5175 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=1]', $result)); |
| 5176 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=1]/JoinThing[something_else_id=1]', $result)); |
| 5177 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=1]/JoinThing[doomed=1]', $result)); |
| 5178 |
|
|
| 5179 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=2]', $result)); |
| 5180 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=2]/JoinThing[something_else_id=2]', $result)); |
| 5181 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=2]/JoinThing[doomed=0]', $result)); |
| 5182 |
|
|
| 5183 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=3]', $result)); |
| 5184 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=3]/JoinThing[something_else_id=3]', $result)); |
| 5185 |
|
$this->assertTrue(Set::matches('/SomethingElse[id=3]/JoinThing[doomed=1]', $result)); |
| 5186 |
|
} |
| 5187 |
|
|
| 5188 |
|
/** |
| 5189 |
|
* testSaveAssociatedHasOne method |