public function test() { $recordsQty = TestUser::all()->count(); if ($recordsQty <= 5) { throw new \Exception("Can't test PaginateProcessor: not enough fixture data"); } $provider = new EloquentDataProvider(TestUser::class); $provider->operations()->add(new PaginateOperation(1, 3)); $data = iterator_to_array($provider); $id1 = array_first($data)->id; self::assertEquals(3, count($data)); $provider = new EloquentDataProvider(DB::table((new TestUser())->getTable())); $provider->operations()->add(new PaginateOperation(2, 2)); $data = iterator_to_array($provider); self::assertEquals(2, count($data)); $id2 = array_first($data)->id; self::assertTrue($id2 > 0 && $id2 > 0 && $id1 !== $id2); }
public function testEloquentBuilderWithPreCondition() { $provider = new EloquentDataProvider(TestUser::where('name', '=', 'David')); self::assertEquals(1, $provider->count()); }