public function testRetrieveByRank() { $t = Table11Peer::retrieveByRank(5); $this->assertNull($t, 'retrieveByRank() returns null for an unknown rank'); $t3 = Table11Peer::retrieveByRank(3); $this->assertEquals(3, $t3->getRank(), 'retrieveByRank() returns the object with the required rank'); $this->assertEquals('row3', $t3->getTitle(), 'retrieveByRank() returns the object with the required rank'); }
public function testPreDeleteFkScope() { $this->populateFkScopeTable(); $t = Table11Peer::retrieveByRank(2); $t->delete(); $expected = array(1 => 'row7', 2 => 'row8', 3 => 'row9', 4 => 'row4', 5 => 'row5', 6 => 'row6'); $this->assertEquals($expected, $this->getFixturesArrayWithFkScope(), 'delete() moves related objects to the end of null scope'); $s = Table11Peer::retrieveByRank(1); $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3'); $this->assertEquals($expected, $this->getFixturesArrayWithFkScope($s->getId()), 'delete() leaves other suites unchanged'); }
protected function populateFkScopeTable() { /* List used for tests scope=1 scope=2 scope=null row1 row4 row7 row2 row5 row8 row3 row6 row9 */ $this->populateTable11(); $s1 = Table11Peer::retrieveByRank(1)->getId(); $s2 = Table11Peer::retrieveByRank(2)->getId(); FkScopeTablePeer::doDeleteAll(); $t1 = new FkScopeTable(); $t1->setRank(1); $t1->setScopeValue($s1); $t1->setTitle('row1'); $t1->save(); $t2 = new FkScopeTable(); $t2->setRank(2); $t2->setScopeValue($s1); $t2->setTitle('row2'); $t2->save(); $t3 = new FkScopeTable(); $t3->setRank(3); $t3->setScopeValue($s1); $t3->setTitle('row3'); $t3->save(); $t4 = new FkScopeTable(); $t4->setRank(1); $t4->setScopeValue($s2); $t4->setTitle('row4'); $t4->save(); $t5 = new FkScopeTable(); $t5->setRank(2); $t5->setScopeValue($s2); $t5->setTitle('row5'); $t5->save(); $t6 = new FkScopeTable(); $t6->setRank(3); $t6->setScopeValue($s2); $t6->setTitle('row6'); $t6->save(); $t7 = new FkScopeTable(); $t7->setRank(1); $t7->setTitle('row7'); $t7->save(); $t8 = new FkScopeTable(); $t8->setRank(2); $t8->setTitle('row8'); $t8->save(); $t9 = new FkScopeTable(); $t9->setRank(3); $t9->setTitle('row9'); $t9->save(); }
public function testRemoveFromList() { $t2 = Table11Peer::retrieveByRank(2); $res = $t2->removeFromList(); $this->assertTrue($res instanceof Table11, 'removeFromList() returns the current object'); $this->assertNull($res->getRank(), 'removeFromList() resets the object\'s rank'); Table11Peer::clearInstancePool(); $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4'); $this->assertEquals($expected, $this->getFixturesArray(), 'removeFromList() does not change the list until the object is saved'); $t2->save(); Table11Peer::clearInstancePool(); $expected = array(null => 'row2', 1 => 'row1', 2 => 'row3', 3 => 'row4'); $this->assertEquals($expected, $this->getFixturesArray(), 'removeFromList() changes the list once the object is saved'); }