コード例 #1
0
 /**
  * @test
  * @todo rewrite this so that it uses listify method instead
  * @todo and add other useful listify methods?
  */
 function it_updates_the_list_position_of_a_record()
 {
     $this->repository->maintenance();
     // check starting situation
     $changeModel = $this->repository->findBy(self::UNIQUE_FIELD, '1337');
     $this->assertEquals(1, $this->repository->findBy(self::UNIQUE_FIELD, '999')->position, "Starting position for record (999) is incorrect");
     $this->assertEquals(3, $changeModel->position, "Starting position for record (1337) is incorrect");
     // update the position of the last added entry
     $this->repository->updatePosition($changeModel->id, 1);
     // check final positions after update
     $this->assertEquals(2, $this->repository->findBy(self::UNIQUE_FIELD, '999')->position, "Final position for record (999) is incorrect");
     $this->assertEquals(1, $this->repository->findBy(self::UNIQUE_FIELD, '1337')->position, "Final position for moved record (1337) is incorrect");
 }