コード例 #1
0
 public function testParameters()
 {
     $table11 = Table11Peer::getTableMap();
     $this->assertEquals(count($table11->getColumns()), 3, 'Sortable adds one columns by default');
     $this->assertTrue(method_exists('\\Propel\\Tests\\Bookstore\\Behavior\\Table11', 'getRank'), 'Sortable adds a rank column by default');
     $table12 = Table12Peer::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\\Table12', 'getPosition'), 'Sortable allows customization of rank_column name');
 }
 public function testRemoveFromList()
 {
     $t2 = Table12Peer::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');
     Table12Peer::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();
     Table12Peer::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');
 }
コード例 #3
0
 protected function getFixturesArrayWithScope($scope = null)
 {
     $c = new Criteria();
     if ($scope !== null) {
         $c->add(Table12Peer::SCOPE_COL, $scope);
     }
     $c->addAscendingOrderByColumn(Table12Peer::RANK_COL);
     $ts = Table12Peer::doSelect($c);
     $ret = array();
     foreach ($ts as $t) {
         $ret[$t->getRank()] = $t->getTitle();
     }
     return $ret;
 }
 public function testDeleteList()
 {
     $this->assertEquals(4, Table12Peer::deleteList(1), 'deleteList() returns the list of objects in the scope');
     $this->assertEquals(2, Table12Peer::doCount(new Criteria()), 'deleteList() deletes the objects in the scope');
     $this->assertEquals(2, Table12Peer::deleteList(2), 'deleteList() returns the list of objects in the scope');
     $this->assertEquals(0, Table12Peer::doCount(new Criteria()), 'deleteList() deletes the objects in the scope');
 }