Skip to content

Commit 7f1910c

Browse files
committed
Use phpunit 13 where possible
1 parent 0a7d90e commit 7f1910c

8 files changed

Lines changed: 36 additions & 5564 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ phpunit.xml
66
/.phpunit.cache/
77
/build/
88
/vendor/
9-
!/vendor-bin/tools/composer.lock
109
/vendor-bin/tools/vendor/
1110
/vendor-bin/tools/bin/

tests/Action/CheckEmailActionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function testWithUsername(): void
8686
;
8787

8888
$this->templateRegistry
89-
->method('getTemplate')
89+
->expects(self::once())->method('getTemplate')
9090
->with('layout')
9191
->willReturn('base.html.twig')
9292
;

tests/Action/LoginActionTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static function (string $message): string {
135135
$request->setSession($session);
136136

137137
$this->router
138-
->method('generate')
138+
->expects(self::once())->method('generate')
139139
->with('sonata_admin_dashboard')
140140
->willReturn('/foo')
141141
;
@@ -165,13 +165,13 @@ public function testUserGrantedAdmin(string $referer, string $expectedRedirectUr
165165
;
166166

167167
$this->router
168-
->method('generate')
168+
->expects(self::once())->method('generate')
169169
->with('sonata_admin_dashboard')
170170
->willReturn('/foo')
171171
;
172172

173173
$this->authorizationChecker->expects(self::once())
174-
->method('isGranted')
174+
->expects(self::once())->method('isGranted')
175175
->with('ROLE_ADMIN')
176176
->willReturn(true)
177177
;
@@ -270,25 +270,25 @@ static function (string $key) use ($sessionParameters): bool {
270270
;
271271

272272
$this->authorizationChecker->expects(self::once())
273-
->method('isGranted')
273+
->expects(self::once())->method('isGranted')
274274
->with('ROLE_ADMIN')
275275
->willReturn(false)
276276
;
277277

278278
$this->csrfTokenManager
279-
->method('getToken')
279+
->expects(self::once())->method('getToken')
280280
->with('authenticate')
281281
->willReturn($csrfToken)
282282
;
283283

284284
$this->templateRegistry
285-
->method('getTemplate')
285+
->expects(self::once())->method('getTemplate')
286286
->with('layout')
287287
->willReturn('base.html.twig')
288288
;
289289

290290
$this->templating
291-
->method('render')
291+
->expects(self::once())->method('render')
292292
->with('@NucleosUserAdmin/Admin/Security/login.html.twig', [
293293
'admin_pool' => $this->pool,
294294
'base_template' => 'base.html.twig',

tests/Action/RequestActionTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function testAuthenticated(): void
7575
;
7676

7777
$this->router
78-
->method('generate')
78+
->expects(self::once())->method('generate')
7979
->with('sonata_admin_dashboard')
8080
->willReturn('/foo')
8181
;
@@ -100,7 +100,7 @@ public function testUnauthenticated(): void
100100
;
101101

102102
$this->templateRegistry
103-
->method('getTemplate')
103+
->expects(self::once())->method('getTemplate')
104104
->with('layout')
105105
->willReturn('base.html.twig')
106106
;
@@ -131,7 +131,7 @@ public function testUnauthenticated(): void
131131
;
132132

133133
$this->router
134-
->method('generate')
134+
->expects(self::once())->method('generate')
135135
->with('nucleos_user_admin_resetting_send_email')
136136
->willReturn('/foo')
137137
;
@@ -147,7 +147,7 @@ public function testUnauthenticated(): void
147147
;
148148

149149
$this->templateRegistry
150-
->method('getTemplate')
150+
->expects(self::once())->method('getTemplate')
151151
->with('layout')
152152
->willReturn('base.html.twig')
153153
;

tests/Action/ResetActionTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function testAuthenticated(): void
116116
;
117117

118118
$this->router
119-
->method('generate')
119+
->expects(self::once())->method('generate')
120120
->with('sonata_admin_dashboard')
121121
->willReturn('/foo')
122122
;
@@ -136,7 +136,7 @@ public function testUnknownToken(): void
136136
$request = new Request();
137137

138138
$this->userManager
139-
->method('findUserByConfirmationToken')
139+
->expects(self::once())->method('findUserByConfirmationToken')
140140
->with('token')
141141
->willReturn(null)
142142
;
@@ -156,13 +156,13 @@ public function testPasswordRequestNonExpired(): void
156156
;
157157

158158
$this->userManager
159-
->method('findUserByConfirmationToken')
159+
->expects(self::once())->method('findUserByConfirmationToken')
160160
->with('token')
161161
->willReturn($user)
162162
;
163163

164164
$this->router
165-
->method('generate')
165+
->expects(self::once())->method('generate')
166166
->with('nucleos_user_admin_resetting_request')
167167
->willReturn('/foo')
168168
;
@@ -204,7 +204,7 @@ public function testReset(): void
204204
;
205205

206206
$this->userManager
207-
->method('findUserByConfirmationToken')
207+
->expects(self::once())->method('findUserByConfirmationToken')
208208
->with('user-token')
209209
->willReturn($user)
210210
;
@@ -215,13 +215,13 @@ public function testReset(): void
215215
;
216216

217217
$this->router
218-
->method('generate')
218+
->expects(self::once())->method('generate')
219219
->with('nucleos_user_admin_security_check')
220220
->willReturn('/check')
221221
;
222222

223223
$this->templating
224-
->method('render')
224+
->expects(self::once())->method('render')
225225
->with('@NucleosUserAdmin/Admin/Security/Resetting/reset.html.twig', [
226226
'token' => 'user-token',
227227
'form' => $view,
@@ -232,7 +232,7 @@ public function testReset(): void
232232
;
233233

234234
$this->templateRegistry
235-
->method('getTemplate')
235+
->expects(self::once())->method('getTemplate')
236236
->with('layout')
237237
->willReturn('base.html.twig')
238238
;
@@ -259,15 +259,15 @@ public function testPostedReset(): void
259259
->method('setLastLogin')
260260
;
261261
$user->expects(self::once())
262-
->method('setConfirmationToken')
262+
->expects(self::once())->method('setConfirmationToken')
263263
->with(null)
264264
;
265265
$user->expects(self::once())
266-
->method('setPasswordRequestedAt')
266+
->expects(self::once())->method('setPasswordRequestedAt')
267267
->with(null)
268268
;
269269
$user->expects(self::once())
270-
->method('setEnabled')
270+
->expects(self::once())->method('setEnabled')
271271
->with(true)
272272
;
273273

@@ -292,7 +292,7 @@ static function (string $message): string {
292292

293293
$bag = $this->createMock(FlashBag::class);
294294
$bag->expects(self::once())
295-
->method('add')
295+
->expects(self::once())->method('add')
296296
->with('success', 'resetting.flash.success')
297297
;
298298

@@ -302,17 +302,17 @@ static function (string $message): string {
302302
;
303303

304304
$this->userManager
305-
->method('findUserByConfirmationToken')
305+
->expects(self::once())->method('findUserByConfirmationToken')
306306
->with('token')
307307
->willReturn($user)
308308
;
309309
$this->userManager->expects(self::once())
310-
->method('updateUser')
310+
->expects(self::once())->method('updateUser')
311311
->with($user)
312312
;
313313

314314
$this->loginManager->expects(self::once())
315-
->method('logInUser')
315+
->expects(self::once())->method('logInUser')
316316
->with('default', $user, self::isInstanceOf(Response::class))
317317
;
318318

tests/Action/SendEmailActionTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ public function testUnknownUsername(): void
7979
$request = new Request([], ['username' => 'bar']);
8080

8181
$this->userProvider
82-
->method('loadUserByIdentifier')
82+
->expects(self::once())->method('loadUserByIdentifier')
8383
->with('bar')
8484
->willThrowException(new UserNotFoundException())
8585
;
8686

8787
$this->urlGenerator
88-
->method('generate')
88+
->expects(self::once())->method('generate')
8989
->with('nucleos_user_admin_resetting_check_email', ['username' => 'bar'])
9090
->willReturn('/check-email')
9191
;
@@ -108,7 +108,7 @@ public function testPasswordRequestNonExpired(): void
108108
;
109109

110110
$this->userProvider
111-
->method('loadUserByIdentifier')
111+
->expects(self::once())->method('loadUserByIdentifier')
112112
->with('bar')
113113
->willReturn($user)
114114
;
@@ -118,7 +118,7 @@ public function testPasswordRequestNonExpired(): void
118118
;
119119

120120
$this->urlGenerator
121-
->method('generate')
121+
->expects(self::once())->method('generate')
122122
->with('nucleos_user_admin_resetting_check_email')
123123
->willReturn('/foo')
124124
;
@@ -145,7 +145,7 @@ public function testAccountLocked(): void
145145
;
146146

147147
$this->userProvider
148-
->method('loadUserByIdentifier')
148+
->expects(self::once())->method('loadUserByIdentifier')
149149
->with('bar')
150150
->willReturn($user)
151151
;
@@ -155,7 +155,7 @@ public function testAccountLocked(): void
155155
;
156156

157157
$this->urlGenerator
158-
->method('generate')
158+
->expects(self::once())->method('generate')
159159
->with('nucleos_user_admin_resetting_request')
160160
->willReturn('/foo')
161161
;
@@ -207,7 +207,7 @@ static function () use (&$storedToken): ?string {
207207
;
208208

209209
$this->userProvider
210-
->method('loadUserByIdentifier')
210+
->expects(self::once())->method('loadUserByIdentifier')
211211
->with('bar')
212212
->willReturn($user)
213213
;
@@ -222,7 +222,7 @@ static function () use (&$storedToken): ?string {
222222
;
223223

224224
$this->urlGenerator
225-
->method('generate')
225+
->expects(self::once())->method('generate')
226226
->with('nucleos_user_admin_resetting_check_email', ['username' => 'bar'])
227227
->willReturn('/check-email')
228228
;

vendor-bin/tools/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"phpstan/phpstan-phpunit": "^2.0.0",
1313
"phpstan/phpstan-strict-rules": "^2.0.0",
1414
"phpstan/phpstan-symfony": "^2.0.0",
15-
"phpunit/phpunit": "^12.0.0",
15+
"phpunit/phpunit": "^12.0.0 || ^13.0.0",
1616
"symfony/phpunit-bridge": "^8.0"
1717
},
1818
"config": {

0 commit comments

Comments
 (0)