99
1010use ArrayIterator ;
1111use Doctrine \ORM \AbstractQuery ;
12- use Doctrine \ORM \QueryBuilder ;
1312use Doctrine \ORM \Tools \Pagination \Paginator ;
1413use PHPUnit \Framework \TestCase ;
1514use Prophecy \Argument ;
15+ use Prophecy \Prophecy \ObjectProphecy ;
1616use Psr \Http \Message \ServerRequestInterface ;
1717use Zend \Expressive \Hal \HalResource ;
1818use Zend \Expressive \Hal \Link ;
2424
2525class DoctrinePaginatorTest extends TestCase
2626{
27+ /** @var ObjectProphecy&RouteBasedCollectionMetadata */
28+ private $ metadata ;
29+
30+ /** @var ObjectProphecy&LinkGenerator */
31+ private $ linkGenerator ;
32+
33+ /** @var ObjectProphecy&ResourceGenerator */
34+ private $ generator ;
35+
36+ /** @var ObjectProphecy&ServerRequestInterface */
37+ private $ request ;
38+
39+ /** @var ObjectProphecy&Paginator */
40+ private $ paginator ;
41+
42+ /** @var RouteBasedCollectionStrategy */
43+ private $ strategy ;
44+
2745 public function setUp ()
2846 {
2947 $ this ->metadata = $ this ->prophesize (RouteBasedCollectionMetadata::class);
@@ -35,15 +53,15 @@ public function setUp()
3553 $ this ->strategy = new RouteBasedCollectionStrategy ();
3654 }
3755
38- public function mockQuery ()
56+ public function mockQuery (): \ PHPUnit \ Framework \ MockObject \ MockObject
3957 {
4058 return $ this ->getMockBuilder (AbstractQuery::class)
4159 ->disableOriginalConstructor ()
4260 ->setMethods (['getMaxResults ' , 'setFirstResult ' ])
4361 ->getMockForAbstractClass ();
4462 }
4563
46- public function mockLinkGeneration (string $ relation , string $ route , array $ routeParams , array $ queryStringArgs )
64+ public function mockLinkGeneration (string $ relation , string $ route , array $ routeParams , array $ queryStringArgs ): void
4765 {
4866 $ link = $ this ->prophesize (Link::class)->reveal ();
4967 $ this ->linkGenerator
@@ -67,7 +85,7 @@ public function invalidPageCombinations() : iterable
6785 /**
6886 * @dataProvider invalidPageCombinations
6987 */
70- public function testThrowsOutOfBoundsExceptionForInvalidPage (int $ page , int $ numPages )
88+ public function testThrowsOutOfBoundsExceptionForInvalidPage (int $ page , int $ numPages ): void
7189 {
7290 $ query = $ this ->mockQuery ();
7391 $ query ->expects ($ this ->once ())
@@ -90,7 +108,7 @@ public function testThrowsOutOfBoundsExceptionForInvalidPage(int $page, int $num
90108 );
91109 }
92110
93- public function testDoesNotCreateLinksForUnknownPaginationParamType ()
111+ public function testDoesNotCreateLinksForUnknownPaginationParamType (): void
94112 {
95113 $ query = $ this ->mockQuery ();
96114 $ query ->expects ($ this ->once ())
@@ -113,7 +131,7 @@ public function testDoesNotCreateLinksForUnknownPaginationParamType()
113131 ->shouldBeCalledTimes (1 );
114132 $ this ->request ->getAttribute (Argument::any (), Argument::any ())->shouldNotBeCalled ();
115133
116- $ values = array_map (function ($ value ) {
134+ $ values = array_map (static function ($ value ) {
117135 return (object ) ['value ' => $ value ];
118136 }, range (46 , 60 ));
119137 $ this ->paginator ->getIterator ()->willReturn (new ArrayIterator ($ values ));
@@ -147,7 +165,7 @@ public function testDoesNotCreateLinksForUnknownPaginationParamType()
147165 $ this ->assertInstanceOf (HalResource::class, $ resource );
148166 }
149167
150- public function testCreatesLinksForQueryBasedPagination ()
168+ public function testCreatesLinksForQueryBasedPagination (): void
151169 {
152170 $ query = $ this ->mockQuery ();
153171 $ query ->expects ($ this ->once ())
@@ -173,7 +191,7 @@ public function testCreatesLinksForQueryBasedPagination()
173191 ->shouldBeCalledTimes (1 );
174192 $ this ->request ->getAttribute (Argument::any (), Argument::any ())->shouldNotBeCalled ();
175193
176- $ values = array_map (function ($ value ) {
194+ $ values = array_map (static function ($ value ) {
177195 return (object ) ['value ' => $ value ];
178196 }, range (46 , 60 ));
179197 $ this ->paginator ->getIterator ()->willReturn (new ArrayIterator ($ values ));
@@ -216,7 +234,7 @@ public function testCreatesLinksForQueryBasedPagination()
216234 $ this ->assertInstanceOf (HalResource::class, $ resource );
217235 }
218236
219- public function testCreatesLinksForRouteBasedPagination ()
237+ public function testCreatesLinksForRouteBasedPagination (): void
220238 {
221239 $ query = $ this ->mockQuery ();
222240 $ query ->expects ($ this ->once ())
@@ -242,7 +260,7 @@ public function testCreatesLinksForRouteBasedPagination()
242260 ->willReturn (3 )
243261 ->shouldBeCalledTimes (1 );
244262
245- $ values = array_map (function ($ value ) {
263+ $ values = array_map (static function ($ value ) {
246264 return (object ) ['value ' => $ value ];
247265 }, range (46 , 60 ));
248266 $ this ->paginator ->getIterator ()->willReturn (new ArrayIterator ($ values ));
0 commit comments