9
9
10
10
use ArrayIterator ;
11
11
use Doctrine \ORM \AbstractQuery ;
12
+ use Doctrine \ORM \QueryBuilder ;
12
13
use Doctrine \ORM \Tools \Pagination \Paginator ;
13
14
use PHPUnit \Framework \TestCase ;
14
15
use Prophecy \Argument ;
15
- use Prophecy \Prophecy \ObjectProphecy ;
16
16
use Psr \Http \Message \ServerRequestInterface ;
17
17
use Zend \Expressive \Hal \HalResource ;
18
18
use Zend \Expressive \Hal \Link ;
24
24
25
25
class DoctrinePaginatorTest extends TestCase
26
26
{
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
-
45
27
public function setUp ()
46
28
{
47
29
$ this ->metadata = $ this ->prophesize (RouteBasedCollectionMetadata::class);
@@ -53,15 +35,15 @@ public function setUp()
53
35
$ this ->strategy = new RouteBasedCollectionStrategy ();
54
36
}
55
37
56
- public function mockQuery (): \ PHPUnit \ Framework \ MockObject \ MockObject
38
+ public function mockQuery ()
57
39
{
58
40
return $ this ->getMockBuilder (AbstractQuery::class)
59
41
->disableOriginalConstructor ()
60
42
->setMethods (['getMaxResults ' , 'setFirstResult ' ])
61
43
->getMockForAbstractClass ();
62
44
}
63
45
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 )
65
47
{
66
48
$ link = $ this ->prophesize (Link::class)->reveal ();
67
49
$ this ->linkGenerator
@@ -85,7 +67,7 @@ public function invalidPageCombinations() : iterable
85
67
/**
86
68
* @dataProvider invalidPageCombinations
87
69
*/
88
- public function testThrowsOutOfBoundsExceptionForInvalidPage (int $ page , int $ numPages ): void
70
+ public function testThrowsOutOfBoundsExceptionForInvalidPage (int $ page , int $ numPages )
89
71
{
90
72
$ query = $ this ->mockQuery ();
91
73
$ query ->expects ($ this ->once ())
@@ -108,7 +90,7 @@ public function testThrowsOutOfBoundsExceptionForInvalidPage(int $page, int $num
108
90
);
109
91
}
110
92
111
- public function testDoesNotCreateLinksForUnknownPaginationParamType (): void
93
+ public function testDoesNotCreateLinksForUnknownPaginationParamType ()
112
94
{
113
95
$ query = $ this ->mockQuery ();
114
96
$ query ->expects ($ this ->once ())
@@ -131,7 +113,7 @@ public function testDoesNotCreateLinksForUnknownPaginationParamType(): void
131
113
->shouldBeCalledTimes (1 );
132
114
$ this ->request ->getAttribute (Argument::any (), Argument::any ())->shouldNotBeCalled ();
133
115
134
- $ values = array_map (static function ($ value ) {
116
+ $ values = array_map (function ($ value ) {
135
117
return (object ) ['value ' => $ value ];
136
118
}, range (46 , 60 ));
137
119
$ this ->paginator ->getIterator ()->willReturn (new ArrayIterator ($ values ));
@@ -165,7 +147,7 @@ public function testDoesNotCreateLinksForUnknownPaginationParamType(): void
165
147
$ this ->assertInstanceOf (HalResource::class, $ resource );
166
148
}
167
149
168
- public function testCreatesLinksForQueryBasedPagination (): void
150
+ public function testCreatesLinksForQueryBasedPagination ()
169
151
{
170
152
$ query = $ this ->mockQuery ();
171
153
$ query ->expects ($ this ->once ())
@@ -191,7 +173,7 @@ public function testCreatesLinksForQueryBasedPagination(): void
191
173
->shouldBeCalledTimes (1 );
192
174
$ this ->request ->getAttribute (Argument::any (), Argument::any ())->shouldNotBeCalled ();
193
175
194
- $ values = array_map (static function ($ value ) {
176
+ $ values = array_map (function ($ value ) {
195
177
return (object ) ['value ' => $ value ];
196
178
}, range (46 , 60 ));
197
179
$ this ->paginator ->getIterator ()->willReturn (new ArrayIterator ($ values ));
@@ -234,7 +216,7 @@ public function testCreatesLinksForQueryBasedPagination(): void
234
216
$ this ->assertInstanceOf (HalResource::class, $ resource );
235
217
}
236
218
237
- public function testCreatesLinksForRouteBasedPagination (): void
219
+ public function testCreatesLinksForRouteBasedPagination ()
238
220
{
239
221
$ query = $ this ->mockQuery ();
240
222
$ query ->expects ($ this ->once ())
@@ -260,7 +242,7 @@ public function testCreatesLinksForRouteBasedPagination(): void
260
242
->willReturn (3 )
261
243
->shouldBeCalledTimes (1 );
262
244
263
- $ values = array_map (static function ($ value ) {
245
+ $ values = array_map (function ($ value ) {
264
246
return (object ) ['value ' => $ value ];
265
247
}, range (46 , 60 ));
266
248
$ this ->paginator ->getIterator ()->willReturn (new ArrayIterator ($ values ));
0 commit comments