|
|
@@ -24,62 +24,62 @@ require_once dirname(__FILE__) . DS . 'ModelTestBase.php';
|
|
|
*/
|
|
|
class ModelWriteTest extends BaseModelTest {
|
|
|
|
|
|
- /**
|
|
|
- * testInsertAnotherHabtmRecordWithSameForeignKey method
|
|
|
- *
|
|
|
- * @access public
|
|
|
- * @return void
|
|
|
- */
|
|
|
- public function testInsertAnotherHabtmRecordWithSameForeignKey() {
|
|
|
- $this->loadFixtures('JoinA', 'JoinB', 'JoinAB', 'JoinC', 'JoinAC');
|
|
|
- $TestModel = new JoinA();
|
|
|
-
|
|
|
- $result = $TestModel->JoinAsJoinB->findById(1);
|
|
|
- $expected = array(
|
|
|
- 'JoinAsJoinB' => array(
|
|
|
- 'id' => 1,
|
|
|
- 'join_a_id' => 1,
|
|
|
- 'join_b_id' => 2,
|
|
|
- 'other' => 'Data for Join A 1 Join B 2',
|
|
|
- 'created' => '2008-01-03 10:56:33',
|
|
|
- 'updated' => '2008-01-03 10:56:33'
|
|
|
- ));
|
|
|
- $this->assertEquals($expected, $result);
|
|
|
+/**
|
|
|
+ * testInsertAnotherHabtmRecordWithSameForeignKey method
|
|
|
+ *
|
|
|
+ * @access public
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testInsertAnotherHabtmRecordWithSameForeignKey() {
|
|
|
+ $this->loadFixtures('JoinA', 'JoinB', 'JoinAB', 'JoinC', 'JoinAC');
|
|
|
+ $TestModel = new JoinA();
|
|
|
|
|
|
- $TestModel->JoinAsJoinB->create();
|
|
|
- $data = array(
|
|
|
+ $result = $TestModel->JoinAsJoinB->findById(1);
|
|
|
+ $expected = array(
|
|
|
+ 'JoinAsJoinB' => array(
|
|
|
+ 'id' => 1,
|
|
|
'join_a_id' => 1,
|
|
|
- 'join_b_id' => 1,
|
|
|
- 'other' => 'Data for Join A 1 Join B 1',
|
|
|
- 'created' => '2008-01-03 10:56:44',
|
|
|
- 'updated' => '2008-01-03 10:56:44'
|
|
|
- );
|
|
|
- $result = $TestModel->JoinAsJoinB->save($data);
|
|
|
- $lastInsertId = $TestModel->JoinAsJoinB->getLastInsertID();
|
|
|
- $data['id'] = $lastInsertId;
|
|
|
- $this->assertEquals($result, array('JoinAsJoinB' => $data));
|
|
|
- $this->assertTrue($lastInsertId != null);
|
|
|
-
|
|
|
- $result = $TestModel->JoinAsJoinB->findById(1);
|
|
|
- $expected = array(
|
|
|
- 'JoinAsJoinB' => array(
|
|
|
- 'id' => 1,
|
|
|
- 'join_a_id' => 1,
|
|
|
- 'join_b_id' => 2,
|
|
|
- 'other' => 'Data for Join A 1 Join B 2',
|
|
|
- 'created' => '2008-01-03 10:56:33',
|
|
|
- 'updated' => '2008-01-03 10:56:33'
|
|
|
- ));
|
|
|
- $this->assertEquals($expected, $result);
|
|
|
+ 'join_b_id' => 2,
|
|
|
+ 'other' => 'Data for Join A 1 Join B 2',
|
|
|
+ 'created' => '2008-01-03 10:56:33',
|
|
|
+ 'updated' => '2008-01-03 10:56:33'
|
|
|
+ ));
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
|
|
|
- $updatedValue = 'UPDATED Data for Join A 1 Join B 2';
|
|
|
- $TestModel->JoinAsJoinB->id = 1;
|
|
|
- $result = $TestModel->JoinAsJoinB->saveField('other', $updatedValue, false);
|
|
|
- $this->assertFalse(empty($result));
|
|
|
+ $TestModel->JoinAsJoinB->create();
|
|
|
+ $data = array(
|
|
|
+ 'join_a_id' => 1,
|
|
|
+ 'join_b_id' => 1,
|
|
|
+ 'other' => 'Data for Join A 1 Join B 1',
|
|
|
+ 'created' => '2008-01-03 10:56:44',
|
|
|
+ 'updated' => '2008-01-03 10:56:44'
|
|
|
+ );
|
|
|
+ $result = $TestModel->JoinAsJoinB->save($data);
|
|
|
+ $lastInsertId = $TestModel->JoinAsJoinB->getLastInsertID();
|
|
|
+ $data['id'] = $lastInsertId;
|
|
|
+ $this->assertEquals($result, array('JoinAsJoinB' => $data));
|
|
|
+ $this->assertTrue($lastInsertId != null);
|
|
|
|
|
|
- $result = $TestModel->JoinAsJoinB->findById(1);
|
|
|
- $this->assertEquals($result['JoinAsJoinB']['other'], $updatedValue);
|
|
|
- }
|
|
|
+ $result = $TestModel->JoinAsJoinB->findById(1);
|
|
|
+ $expected = array(
|
|
|
+ 'JoinAsJoinB' => array(
|
|
|
+ 'id' => 1,
|
|
|
+ 'join_a_id' => 1,
|
|
|
+ 'join_b_id' => 2,
|
|
|
+ 'other' => 'Data for Join A 1 Join B 2',
|
|
|
+ 'created' => '2008-01-03 10:56:33',
|
|
|
+ 'updated' => '2008-01-03 10:56:33'
|
|
|
+ ));
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $updatedValue = 'UPDATED Data for Join A 1 Join B 2';
|
|
|
+ $TestModel->JoinAsJoinB->id = 1;
|
|
|
+ $result = $TestModel->JoinAsJoinB->saveField('other', $updatedValue, false);
|
|
|
+ $this->assertFalse(empty($result));
|
|
|
+
|
|
|
+ $result = $TestModel->JoinAsJoinB->findById(1);
|
|
|
+ $this->assertEquals($result['JoinAsJoinB']['other'], $updatedValue);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* testSaveDateAsFirstEntry method
|