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');
 }
 public function testDeleteList()
 {
     $this->assertEquals(4, SortableTable12Query::deleteList(null), 'deleteList() returns the list of deleted objects in the scope');
     $this->assertEquals(6, SortableTable12Query::create()->count(), 'deleteList() deletes the objects in the scope');
     $this->assertEquals(4, SortableTable12Query::deleteList(1), 'deleteList() returns the list of deleted objects in the scope');
     $this->assertEquals(2, SortableTable12Query::create()->count(), 'deleteList() deletes the objects in the scope');
     $this->assertEquals(2, SortableTable12Query::deleteList(2), 'deleteList() returns the list of deleted objects in the scope');
     $this->assertEquals(0, SortableTable12Query::create()->count(), 'deleteList() deletes the objects in the scope');
 }
 /**
  * @expectedException Propel\Runtime\Exception\PropelException
  */
 public function testRemoveFromListNoScope()
 {
     $t2 = SortableTable12Query::retrieveByRank(2);
     $t2->removeFromList();
 }
 public function testReorder()
 {
     $objects = SortableTable12Query::create()->findList(1);
     $ids = [];
     foreach ($objects as $object) {
         $ids[] = $object->getPrimaryKey();
     }
     $ranks = [4, 3, 2, 1];
     $order = array_combine($ids, $ranks);
     SortableTable12Query::create()->reorder($order);
     $expected = [1 => 'row4', 2 => 'row3', 3 => 'row2', 4 => 'row1'];
     $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'reorder() reorders the suite');
     $expected = [1 => 'row5', 2 => 'row6'];
     $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'reorder() leaves other suites unchanged');
 }
Example #5
0
 protected function getFixturesArrayWithScope($scope = null)
 {
     $c = new Criteria();
     $c->add(SortableTable12TableMap::SCOPE_COL, $scope);
     $ts = SortableTable12Query::create(null, $c)->orderByPosition()->find();
     $ret = [];
     foreach ($ts as $t) {
         $ret[$t->getRank()] = $t->getTitle();
     }
     return $ret;
 }