Beispiel #1
0
 public function testGetListWithException()
 {
     $changelogTableName = 'viewIdtest_cl';
     $this->mockIsTableExists($changelogTableName, false);
     $this->mockGetTableName();
     $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist");
     $this->model->setViewId('viewIdtest');
     $this->model->getList(mt_rand(1, 200), mt_rand(201, 400));
 }
 /**
  * Test for getList() method
  *
  * @return void
  */
 public function testGetList()
 {
     $this->assertEquals(0, $this->model->getVersion());
     //the same that a table is empty
     $changelogName = $this->resource->getTableName($this->model->getName());
     $testChengelogData = [['version_id' => 1, 'entity_id' => 1], ['version_id' => 2, 'entity_id' => 1], ['version_id' => 3, 'entity_id' => 2], ['version_id' => 4, 'entity_id' => 3], ['version_id' => 5, 'entity_id' => 1]];
     foreach ($testChengelogData as $data) {
         $this->connection->insert($changelogName, $data);
     }
     $this->assertEquals(5, $this->model->getVersion());
     $this->assertEquals(3, count($this->model->getList(0, 5)));
     //distinct entity_ids
     $this->assertEquals(3, count($this->model->getList(2, 5)));
     //distinct entity_ids
     $this->assertEquals(2, count($this->model->getList(0, 3)));
     //distinct entity_ids
     $this->assertEquals(1, count($this->model->getList(0, 2)));
     //distinct entity_ids
     $this->assertEquals(1, count($this->model->getList(2, 3)));
     //distinct entity_ids
     $this->assertEquals(0, count($this->model->getList(4, 3)));
     //because fromVersionId > toVersionId
 }