12
12
namespace Symfony \Cmf \Bundle \RoutingBundle \Tests \Unit \Doctrine \Phpcr ;
13
13
14
14
use Doctrine \ODM \PHPCR \DocumentManager ;
15
- use Doctrine \ODM \PHPCR \Query \Builder \ConstraintFactory ;
15
+ use Doctrine \ODM \PHPCR \Query \Builder \ConstraintOrx ;
16
16
use Doctrine \ODM \PHPCR \Query \Builder \QueryBuilder ;
17
+ use Doctrine \ODM \PHPCR \Query \Builder \WhereAnd ;
17
18
use Doctrine \ODM \PHPCR \Translation \LocaleChooser \LocaleChooserInterface ;
18
19
use Doctrine \Persistence \ManagerRegistry ;
19
20
use PHPUnit \Framework \TestCase ;
22
23
23
24
class PrefixCandidatesTest extends TestCase
24
25
{
25
- public function testAddPrefix ()
26
+ public function testAddPrefix (): void
26
27
{
27
28
$ candidates = new PrefixCandidates (['/routes ' ]);
28
29
$ this ->assertEquals (['/routes ' ], $ candidates ->getPrefixes ());
@@ -32,7 +33,7 @@ public function testAddPrefix()
32
33
$ this ->assertEquals (['/other ' ], $ candidates ->getPrefixes ());
33
34
}
34
35
35
- public function testGetCandidates ()
36
+ public function testGetCandidates (): void
36
37
{
37
38
$ request = Request::create ('/my/path.html ' );
38
39
@@ -54,7 +55,7 @@ public function testGetCandidates()
54
55
);
55
56
}
56
57
57
- public function testGetCandidatesPercentEncoded ()
58
+ public function testGetCandidatesPercentEncoded (): void
58
59
{
59
60
$ request = Request::create ('/my/path%20percent%20encoded.html ' );
60
61
@@ -76,7 +77,7 @@ public function testGetCandidatesPercentEncoded()
76
77
);
77
78
}
78
79
79
- public function testGetCandidatesLocales ()
80
+ public function testGetCandidatesLocales (): void
80
81
{
81
82
$ request = Request::create ('/de/path.html ' );
82
83
@@ -102,16 +103,15 @@ public function testGetCandidatesLocales()
102
103
);
103
104
}
104
105
105
- public function testGetCandidatesLocalesDm ()
106
+ public function testGetCandidatesLocalesDm (): void
106
107
{
107
108
$ request = Request::create ('/de/path.html ' );
108
109
109
110
$ dmMock = $ this ->createMock (DocumentManager::class);
110
111
$ managerRegistryMock = $ this ->createMock (ManagerRegistry::class);
111
112
$ managerRegistryMock
112
- ->expects ($ this ->any ())
113
113
->method ('getManager ' )
114
- ->will ( $ this -> returnValue ( $ dmMock) )
114
+ ->willReturn ( $ dmMock )
115
115
;
116
116
$ localeMock = $ this ->createMock (LocaleChooserInterface::class);
117
117
$ localeMock
@@ -122,14 +122,14 @@ public function testGetCandidatesLocalesDm()
122
122
$ dmMock
123
123
->expects ($ this ->once ())
124
124
->method ('getLocaleChooserStrategy ' )
125
- ->will ( $ this -> returnValue ( $ localeMock) )
125
+ ->willReturn ( $ localeMock )
126
126
;
127
127
128
128
$ candidates = new PrefixCandidates (['/simple ' ], ['de ' , 'fr ' ], $ managerRegistryMock );
129
129
$ candidates ->getCandidates ($ request );
130
130
}
131
131
132
- public function testGetCandidatesLocalesDmNoLocale ()
132
+ public function testGetCandidatesLocalesDmNoLocale (): void
133
133
{
134
134
$ request = Request::create ('/it/path.html ' );
135
135
$ managerRegistryMock = $ this ->createMock (ManagerRegistry::class);
@@ -142,7 +142,7 @@ public function testGetCandidatesLocalesDmNoLocale()
142
142
$ candidates ->getCandidates ($ request );
143
143
}
144
144
145
- public function testIsCandidate ()
145
+ public function testIsCandidate (): void
146
146
{
147
147
$ candidates = new PrefixCandidates (['/routes ' ]);
148
148
$ this ->assertTrue ($ candidates ->isCandidate ('/routes ' ));
@@ -152,33 +152,33 @@ public function testIsCandidate()
152
152
$ this ->assertFalse ($ candidates ->isCandidate ('/routesnotsame ' ));
153
153
}
154
154
155
- public function testRestrictQuery ()
155
+ public function testRestrictQuery (): void
156
156
{
157
- $ orX = $ this ->createMock (ConstraintFactory ::class);
157
+ $ orX = $ this ->createMock (ConstraintOrx ::class);
158
158
$ orX ->expects ($ this ->once ())
159
159
->method ('descendant ' )
160
160
->with ('/routes ' , 'd ' )
161
161
;
162
- $ andWhere = $ this ->createMock (ConstraintFactory ::class);
162
+ $ andWhere = $ this ->createMock (WhereAnd ::class);
163
163
$ andWhere ->expects ($ this ->once ())
164
164
->method ('orX ' )
165
- ->will ( $ this -> returnValue ( $ orX) )
165
+ ->willReturn ( $ orX )
166
166
;
167
167
$ qb = $ this ->createMock (QueryBuilder::class);
168
168
$ qb ->expects ($ this ->once ())
169
169
->method ('andWhere ' )
170
- ->will ( $ this -> returnValue ( $ andWhere) )
170
+ ->willReturn ( $ andWhere )
171
171
;
172
172
$ qb ->expects ($ this ->once ())
173
173
->method ('getPrimaryAlias ' )
174
- ->will ( $ this -> returnValue ( 'd ' ) )
174
+ ->willReturn ( 'd ' )
175
175
;
176
176
177
177
$ candidates = new PrefixCandidates (['/routes ' ]);
178
178
$ candidates ->restrictQuery ($ qb );
179
179
}
180
180
181
- public function testRestrictQueryGlobal ()
181
+ public function testRestrictQueryGlobal (): void
182
182
{
183
183
$ qb = $ this ->createMock (QueryBuilder::class);
184
184
$ qb ->expects ($ this ->never ())
0 commit comments