77use Dingo \Api \Tests \BaseTestCase ;
88use Dingo \Api \Tests \Stubs \UserStub ;
99use Dingo \Api \Transformer \Factory as TransformerFactory ;
10+ use Illuminate \Pagination \LengthAwarePaginator ;
1011use Illuminate \Pagination \Paginator ;
1112use Illuminate \Support \Collection ;
1213use PHPOpenSourceSaver \Fractal \Manager ;
@@ -27,6 +28,7 @@ class FactoryTest extends BaseTestCase
2728
2829 public function setUp (): void
2930 {
31+ parent ::setUp ();
3032 $ this ->transformer = Mockery::mock (TransformerFactory::class);
3133 $ this ->factory = new Factory ($ this ->transformer );
3234 }
@@ -127,6 +129,16 @@ public function testMakingItemResponseWithThreeParameters()
127129 }
128130
129131 public function testMakingPaginatorRegistersUnderlyingClassWithTransformer ()
132+ {
133+ $ this ->setupTranslator ();
134+
135+ $ this ->transformer ->shouldReceive ('register ' )->twice ()->with (UserStub::class, 'test ' , [], null );
136+
137+ $ this ->assertInstanceOf (LengthAwarePaginator::class, $ this ->factory ->paginator (new LengthAwarePaginator ([new UserStub ('Jason ' )], 1 , 1 ), 'test ' )->getOriginalContent ());
138+ $ this ->assertInstanceOf (LengthAwarePaginator::class, $ this ->factory ->withPaginator (new LengthAwarePaginator ([new UserStub ('Jason ' )], 1 , 1 ), 'test ' )->getOriginalContent ());
139+ }
140+
141+ public function testMakingSimplePaginatorRegistersUnderlyingClassWithTransformer ()
130142 {
131143 $ this ->transformer ->shouldReceive ('register ' )->twice ()->with (UserStub::class, 'test ' , [], null );
132144
0 commit comments