public function testGetMaxRank()
 {
     $this->assertEquals(4, SortableTable11Query::create()->getMaxRank(), 'getMaxRank() returns the maximum rank');
     $t4 = SortableTable11Query::retrieveByRank(4);
     $t4->delete();
     $this->assertEquals(3, SortableTable11Query::create()->getMaxRank(), 'getMaxRank() returns the maximum rank');
     SortableTable11TableMap::doDeleteAll();
     $this->assertNull(SortableTable11Query::create()->getMaxRank(), 'getMaxRank() returns null for empty tables');
 }
 public function testParameters()
 {
     $table11 = SortableTable11TableMap::getTableMap();
     $this->assertEquals(count($table11->getColumns()), 3, 'Sortable adds one columns by default');
     $this->assertTrue(method_exists('Propel\\Tests\\Bookstore\\Behavior\\SortableTable11', 'getRank'), 'Sortable adds a rank column by default');
     $table12 = SortableTable12TableMap::getTableMap();
     $this->assertEquals(count($table12->getColumns()), 4, 'Sortable does not add a column when it already exists');
     $this->assertTrue(method_exists('Propel\\Tests\\Bookstore\\Behavior\\SortableTable12', 'getPosition'), 'Sortable allows customization of rank_column name');
 }
Example #3
0
 protected function populateTable11()
 {
     SortableTable11TableMap::doDeleteAll();
     $t1 = new SortableTable11();
     $t1->setRank(1);
     $t1->setTitle('row1');
     $t1->save();
     $t2 = new SortableTable11();
     $t2->setRank(4);
     $t2->setTitle('row4');
     $t2->save();
     $t3 = new SortableTable11();
     $t3->setRank(2);
     $t3->setTitle('row2');
     $t3->save();
     $t4 = new SortableTable11();
     $t4->setRank(3);
     $t4->setTitle('row3');
     $t4->save();
 }
 public function testRemoveFromList()
 {
     $t2 = SortableTable11Query::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');
     SortableTable11TableMap::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();
     SortableTable11TableMap::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');
 }