public function testQueryLimit() { $repository = new TestRepository(); $all = $repository->scope(function ($q) { $q->take(5); })->all(); $this->assertTrue(count($all) == 5); }
public function testPartialTransactionFail() { $repository = new TestRepository(); $repository->beginTransaction(); $repository->save(['title' => 'test existing', 'seq' => 11]); $repository->rollback(); $this->assertTrue($repository->count() == $this->count); }
public function testDataTableLimitedFields() { $repo = new TestRepository(); $result = $repo->scope(function ($query) { $query->select(['id', 'seq']); })->dataTable($this->getRequestMock(0, 5, 1)); $this->assertEquals(1, $result->draw); $this->assertEquals(10, $result->recordsTotal); $this->assertEquals(10, $result->recordsFiltered); $this->assertTrue(is_array($result->data)); $this->assertEquals(5, count($result->data)); $this->assertEquals(2, count($result->data[0])); }