44
55use Illuminate \Database \Eloquent \Builder ;
66use Illuminate \Database \Eloquent \Model ;
7+ use Illuminate \Pagination \LengthAwarePaginator ;
78use LumenApiQueryParser \BuilderParamsApplierTrait ;
89use LumenApiQueryParser \Params \Connection ;
910use LumenApiQueryParser \Params \Filter ;
@@ -33,7 +34,8 @@ public function parametersAppliedCorrectly()
3334 $ modelMock = Mockery::mock (Model::class);
3435 $ modelMock ->shouldReceive ('getTable ' )->times (3 )->andReturn ('user ' );
3536 $ mock ->shouldReceive ('getModel ' )->times (3 )->andReturn ($ modelMock );
36- $ mock ->shouldReceive ('get ' )->once ()->andReturn (true );
37+ $ mock ->shouldReceive ('count ' )->andReturn (1 );
38+ $ mock ->shouldReceive ('paginate ' )->andReturn (new LengthAwarePaginator (collect (['Test ' ]), 1 , 1 , 1 ));
3739
3840 $ params = new RequestParams ();
3941 $ params ->addConnection (new Connection ('children1 ' ));
@@ -44,7 +46,7 @@ public function parametersAppliedCorrectly()
4446 $ params ->addSort (new Sort ('property ' ));
4547 $ params ->addPagination (new Pagination (20 , 2 ));
4648
47- $ this ->assertTrue ( $ this ->applyParams ($ mock , $ params ));
49+ $ this ->assertInstanceOf (LengthAwarePaginator::class , $ this ->applyParams ($ mock , $ params ));
4850 }
4951
5052 /**
@@ -57,8 +59,9 @@ public function noParamersApplied()
5759 $ mock ->shouldNotReceive ('limit ' );
5860 $ mock ->shouldNotReceive ('offset ' );
5961 $ mock ->shouldNotReceive ('where ' );
60- $ mock ->shouldReceive ('get ' )->once ()->andReturn (true );
62+ $ mock ->shouldReceive ('count ' )->andReturn (0 );
63+ $ mock ->shouldReceive ('paginate ' )->andReturn (new LengthAwarePaginator (collect ([]), 0 , 1 , 1 ));
6164
62- $ this ->assertTrue ( $ this ->applyParams ($ mock , new RequestParams ()));
65+ $ this ->assertInstanceOf (LengthAwarePaginator::class , $ this ->applyParams ($ mock , new RequestParams ()));
6366 }
6467}
0 commit comments