99
1010use ArrayIterator ;
1111use Doctrine \ORM \AbstractQuery ;
12+ use Doctrine \ORM \QueryBuilder ;
1213use Doctrine \ORM \Tools \Pagination \Paginator ;
1314use PHPUnit \Framework \TestCase ;
1415use 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-
4527 public function setUp ()
4628 {
4729 $ this ->metadata = $ this ->prophesize (RouteBasedCollectionMetadata::class);
@@ -53,15 +35,15 @@ public function setUp()
5335 $ this ->strategy = new RouteBasedCollectionStrategy ();
5436 }
5537
56- public function mockQuery (): \ PHPUnit \ Framework \ MockObject \ MockObject
38+ public function mockQuery ()
5739 {
5840 return $ this ->getMockBuilder (AbstractQuery::class)
5941 ->disableOriginalConstructor ()
6042 ->setMethods (['getMaxResults ' , 'setFirstResult ' ])
6143 ->getMockForAbstractClass ();
6244 }
6345
64- public function mockLinkGeneration (string $ relation , string $ route , array $ routeParams , array $ queryStringArgs ): void
46+ public function mockLinkGeneration (string $ relation , string $ route , array $ routeParams , array $ queryStringArgs )
6547 {
6648 $ link = $ this ->prophesize (Link::class)->reveal ();
6749 $ this ->linkGenerator
@@ -85,7 +67,7 @@ public function invalidPageCombinations() : iterable
8567 /**
8668 * @dataProvider invalidPageCombinations
8769 */
88- public function testThrowsOutOfBoundsExceptionForInvalidPage (int $ page , int $ numPages ): void
70+ public function testThrowsOutOfBoundsExceptionForInvalidPage (int $ page , int $ numPages )
8971 {
9072 $ query = $ this ->mockQuery ();
9173 $ query ->expects ($ this ->once ())
@@ -108,7 +90,7 @@ public function testThrowsOutOfBoundsExceptionForInvalidPage(int $page, int $num
10890 );
10991 }
11092
111- public function testDoesNotCreateLinksForUnknownPaginationParamType (): void
93+ public function testDoesNotCreateLinksForUnknownPaginationParamType ()
11294 {
11395 $ query = $ this ->mockQuery ();
11496 $ query ->expects ($ this ->once ())
@@ -131,7 +113,7 @@ public function testDoesNotCreateLinksForUnknownPaginationParamType(): void
131113 ->shouldBeCalledTimes (1 );
132114 $ this ->request ->getAttribute (Argument::any (), Argument::any ())->shouldNotBeCalled ();
133115
134- $ values = array_map (static function ($ value ) {
116+ $ values = array_map (function ($ value ) {
135117 return (object ) ['value ' => $ value ];
136118 }, range (46 , 60 ));
137119 $ this ->paginator ->getIterator ()->willReturn (new ArrayIterator ($ values ));
@@ -165,7 +147,7 @@ public function testDoesNotCreateLinksForUnknownPaginationParamType(): void
165147 $ this ->assertInstanceOf (HalResource::class, $ resource );
166148 }
167149
168- public function testCreatesLinksForQueryBasedPagination (): void
150+ public function testCreatesLinksForQueryBasedPagination ()
169151 {
170152 $ query = $ this ->mockQuery ();
171153 $ query ->expects ($ this ->once ())
@@ -191,7 +173,7 @@ public function testCreatesLinksForQueryBasedPagination(): void
191173 ->shouldBeCalledTimes (1 );
192174 $ this ->request ->getAttribute (Argument::any (), Argument::any ())->shouldNotBeCalled ();
193175
194- $ values = array_map (static function ($ value ) {
176+ $ values = array_map (function ($ value ) {
195177 return (object ) ['value ' => $ value ];
196178 }, range (46 , 60 ));
197179 $ this ->paginator ->getIterator ()->willReturn (new ArrayIterator ($ values ));
@@ -234,7 +216,7 @@ public function testCreatesLinksForQueryBasedPagination(): void
234216 $ this ->assertInstanceOf (HalResource::class, $ resource );
235217 }
236218
237- public function testCreatesLinksForRouteBasedPagination (): void
219+ public function testCreatesLinksForRouteBasedPagination ()
238220 {
239221 $ query = $ this ->mockQuery ();
240222 $ query ->expects ($ this ->once ())
@@ -260,7 +242,7 @@ public function testCreatesLinksForRouteBasedPagination(): void
260242 ->willReturn (3 )
261243 ->shouldBeCalledTimes (1 );
262244
263- $ values = array_map (static function ($ value ) {
245+ $ values = array_map (function ($ value ) {
264246 return (object ) ['value ' => $ value ];
265247 }, range (46 , 60 ));
266248 $ this ->paginator ->getIterator ()->willReturn (new ArrayIterator ($ values ));
0 commit comments