/** * testHabtmSaveKeyResolution method * * @return void */ public function testHabtmSaveKeyResolution() { $this->loadFixtures('Apple', 'Device', 'ThePaperMonkies'); $ThePaper = new ThePaper(); $ThePaper->id = 1; $ThePaper->save(array('Monkey' => array(2, 3))); $result = $ThePaper->findById(1); $expected = array(array('id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1'), array('id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2')); $this->assertEquals($expected, $result['Monkey']); $ThePaper->id = 2; $ThePaper->save(array('Monkey' => array(1, 2, 3))); $result = $ThePaper->findById(2); $expected = array(array('id' => '1', 'device_type_id' => '1', 'name' => 'Device 1', 'typ' => '1'), array('id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1'), array('id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2')); $this->assertEquals($expected, $result['Monkey']); $ThePaper->id = 2; $ThePaper->save(array('Monkey' => array(1, 3))); $result = $ThePaper->findById(2); $expected = array(array('id' => '1', 'device_type_id' => '1', 'name' => 'Device 1', 'typ' => '1'), array('id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2')); $this->assertEquals($expected, $result['Monkey']); $result = $ThePaper->findById(1); $expected = array(array('id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1'), array('id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2')); $this->assertEquals($expected, $result['Monkey']); }
/** * testHabtmDeleteLinksWhenNoPrimaryKeyInJoinTable method * * @return void */ public function testHabtmDeleteLinksWhenNoPrimaryKeyInJoinTable() { $this->loadFixtures('Apple', 'Device', 'ThePaperMonkies'); $ThePaper = new ThePaper(); $ThePaper->id = 1; $ThePaper->save(array('Monkey' => array(2, 3))); $result = $ThePaper->findById(1); $expected = array(array('id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1'), array('id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2')); $this->assertEquals($expected, $result['Monkey']); $ThePaper = new ThePaper(); $ThePaper->id = 2; $ThePaper->save(array('Monkey' => array(2, 3))); $result = $ThePaper->findById(2); $expected = array(array('id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1'), array('id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2')); $this->assertEquals($expected, $result['Monkey']); $ThePaper->delete(1); $result = $ThePaper->findById(2); $expected = array(array('id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1'), array('id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2')); $this->assertEquals($expected, $result['Monkey']); }