Esempio n. 1
0
 protected function populateTable12()
 {
     /* List used for tests
         scope=1   scope=2   scope=null
         row1      row5      row7
         row2      row6      row8
         row3                row9
         row4                row10
        */
     SortableTable12TableMap::doDeleteAll();
     $t1 = new SortableTable12();
     $t1->setRank(1);
     $t1->setScopeValue(1);
     $t1->setTitle('row1');
     $t1->save();
     $t2 = new SortableTable12();
     $t2->setRank(4);
     $t2->setScopeValue(1);
     $t2->setTitle('row4');
     $t2->save();
     $t3 = new SortableTable12();
     $t3->setRank(2);
     $t3->setScopeValue(1);
     $t3->setTitle('row2');
     $t3->save();
     $t4 = new SortableTable12();
     $t4->setRank(1);
     $t4->setScopeValue(2);
     $t4->setTitle('row5');
     $t4->save();
     $t5 = new SortableTable12();
     $t5->setRank(3);
     $t5->setScopeValue(1);
     $t5->setTitle('row3');
     $t5->save();
     $t6 = new SortableTable12();
     $t6->setRank(2);
     $t6->setScopeValue(2);
     $t6->setTitle('row6');
     $t6->save();
     $t7 = new SortableTable12();
     $t7->setRank(1);
     $t7->setTitle('row7');
     $t7->save();
     $t8 = new SortableTable12();
     $t8->setRank(2);
     $t8->setTitle('row8');
     $t8->save();
     $t9 = new SortableTable12();
     $t9->setRank(3);
     $t9->setTitle('row9');
     $t9->save();
     $t10 = new SortableTable12();
     $t10->setRank(4);
     $t10->setTitle('row10');
     $t10->save();
 }
 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');
 }
 public function testGetMaxRank()
 {
     $this->assertEquals(4, SortableTable12Query::create()->getMaxRank(1), 'getMaxRank() returns the maximum rank of the suite');
     $this->assertEquals(2, SortableTable12Query::create()->getMaxRank(2), 'getMaxRank() returns the maximum rank of the suite');
     $t4 = SortableTable12Query::retrieveByRank(4, 1);
     $t4->delete();
     $this->assertEquals(3, SortableTable12Query::create()->getMaxRank(1), 'getMaxRank() returns the maximum rank');
     SortableTable12TableMap::doDeleteAll();
     $this->assertNull(SortableTable12Query::create()->getMaxRank(1), 'getMaxRank() returns null for empty tables');
 }
Esempio n. 4
0
 protected function populateTable12()
 {
     /* List used for tests
        scope=1   scope=2
        row1      row5
        row2      row6
        row3
        row4
        */
     SortableTable12TableMap::doDeleteAll();
     $t1 = new SortableTable12();
     $t1->setRank(1);
     $t1->setScopeValue(1);
     $t1->setTitle('row1');
     $t1->save();
     $t2 = new SortableTable12();
     $t2->setRank(4);
     $t2->setScopeValue(1);
     $t2->setTitle('row4');
     $t2->save();
     $t3 = new SortableTable12();
     $t3->setRank(2);
     $t3->setScopeValue(1);
     $t3->setTitle('row2');
     $t3->save();
     $t4 = new SortableTable12();
     $t4->setRank(1);
     $t4->setScopeValue(2);
     $t4->setTitle('row5');
     $t4->save();
     $t5 = new SortableTable12();
     $t5->setRank(3);
     $t5->setScopeValue(1);
     $t5->setTitle('row3');
     $t5->save();
     $t6 = new SortableTable12();
     $t6->setRank(2);
     $t6->setScopeValue(2);
     $t6->setTitle('row6');
     $t6->save();
 }
 public function testRemoveFromList()
 {
     $t2 = SortableTable12Query::retrieveByRank(2, 1);
     $res = $t2->removeFromList();
     $this->assertTrue($res instanceof Table12, 'removeFromList() returns the current object');
     $this->assertNull($res->getRank(), 'removeFromList() resets the object\'s rank');
     SortableTable12TableMap::clearInstancePool();
     $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4');
     $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'removeFromList() does not change the list until the object is saved');
     $t2->save();
     SortableTable12TableMap::clearInstancePool();
     $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4');
     $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'removeFromList() changes the list once the object is saved');
     $expected = array(1 => 'row5', 2 => 'row6');
     $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'removeFromList() leaves other suites unchanged');
 }