Skip to content

Commit 0ae4c46

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

8 files changed

Lines changed: 72 additions & 5600 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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public function testWithoutUsername(): void
5656
{
5757
$request = new Request();
5858

59-
$this->urlGenerator->expects(self::once())
60-
->method('generate')
59+
$this->urlGenerator
60+
->expects(self::once())->method('generate')
6161
->with('nucleos_user_admin_resetting_request')
6262
->willReturn('/foo')
6363
;
@@ -79,14 +79,14 @@ public function testWithUsername(): void
7979
'tokenLifetime' => 1,
8080
];
8181

82-
$this->templating->expects(self::once())
83-
->method('render')
82+
$this->templating
83+
->expects(self::once())->method('render')
8484
->with('@NucleosUserAdmin/Admin/Security/Resetting/checkEmail.html.twig', $parameters)
8585
->willReturn('template content')
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: 13 additions & 13 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

173-
$this->authorizationChecker->expects(self::once())
174-
->method('isGranted')
173+
$this->authorizationChecker
174+
->expects(self::once())->method('isGranted')
175175
->with('ROLE_ADMIN')
176176
->willReturn(true)
177177
;
@@ -251,13 +251,13 @@ static function (string $key) use ($sessionParameters): bool {
251251
->method('add')
252252
->willReturnSelf()
253253
;
254-
$form->expects(self::once())
255-
->method('createView')
254+
$form
255+
->expects(self::once())->method('createView')
256256
->willReturn($view)
257257
;
258258

259-
$this->formFactory->expects(self::once())
260-
->method('create')
259+
$this->formFactory
260+
->expects(self::once())->method('create')
261261
->willReturn($form)
262262
;
263263

@@ -269,26 +269,26 @@ static function (string $key) use ($sessionParameters): bool {
269269
->willReturnOnConsecutiveCalls('/check', '/reset')
270270
;
271271

272-
$this->authorizationChecker->expects(self::once())
273-
->method('isGranted')
272+
$this->authorizationChecker
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: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ public function testAuthenticated(): void
6969
{
7070
$request = new Request();
7171

72-
$this->authorizationChecker->expects(self::once())
73-
->method('isGranted')
72+
$this->authorizationChecker
73+
->expects(self::once())->method('isGranted')
7474
->willReturn(true)
7575
;
7676

7777
$this->router
78-
->method('generate')
78+
->expects(self::once())->method('generate')
7979
->with('sonata_admin_dashboard')
8080
->willReturn('/foo')
8181
;
@@ -94,13 +94,13 @@ public function testUnauthenticated(): void
9494
{
9595
$request = new Request();
9696

97-
$this->authorizationChecker->expects(self::once())
98-
->method('isGranted')
97+
$this->authorizationChecker
98+
->expects(self::once())->method('isGranted')
9999
->willReturn(false)
100100
;
101101

102102
$this->templateRegistry
103-
->method('getTemplate')
103+
->expects(self::once())->method('getTemplate')
104104
->with('layout')
105105
->willReturn('base.html.twig')
106106
;
@@ -116,28 +116,28 @@ public function testUnauthenticated(): void
116116
->method('isSubmitted')
117117
->willReturn(false)
118118
;
119-
$form->expects(self::once())
120-
->method('createView')
119+
$form
120+
->expects(self::once())->method('createView')
121121
->willReturn($view)
122122
;
123123
$form
124124
->method('add')
125125
->willReturnSelf()
126126
;
127127

128-
$this->formFactory->expects(self::once())
129-
->method('create')
128+
$this->formFactory
129+
->expects(self::once())->method('create')
130130
->willReturn($form)
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
;
138138

139-
$this->templating->expects(self::once())
140-
->method('render')
139+
$this->templating
140+
->expects(self::once())->method('render')
141141
->with('@NucleosUserAdmin/Admin/Security/Resetting/request.html.twig', [
142142
'base_template' => 'base.html.twig',
143143
'admin_pool' => $this->pool,
@@ -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: 27 additions & 27 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
;
@@ -198,13 +198,13 @@ public function testReset(): void
198198
->method('isSubmitted')
199199
->willReturn(false)
200200
;
201-
$form->expects(self::once())
202-
->method('createView')
201+
$form
202+
->expects(self::once())->method('createView')
203203
->willReturn($view)
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
;
@@ -255,19 +255,19 @@ public function testPostedReset(): void
255255
->method('isPasswordRequestNonExpired')
256256
->willReturn(true)
257257
;
258-
$user->expects(self::once())
259-
->method('setLastLogin')
258+
$user
259+
->expects(self::once())->method('setLastLogin')
260260
;
261-
$user->expects(self::once())
262-
->method('setConfirmationToken')
261+
$user
262+
->expects(self::once())->method('setConfirmationToken')
263263
->with(null)
264264
;
265-
$user->expects(self::once())
266-
->method('setPasswordRequestedAt')
265+
$user
266+
->expects(self::once())->method('setPasswordRequestedAt')
267267
->with(null)
268268
;
269-
$user->expects(self::once())
270-
->method('setEnabled')
269+
$user
270+
->expects(self::once())->method('setEnabled')
271271
->with(true)
272272
;
273273

@@ -291,8 +291,8 @@ static function (string $message): string {
291291
;
292292

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

@@ -302,22 +302,22 @@ 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
;
309-
$this->userManager->expects(self::once())
310-
->method('updateUser')
309+
$this->userManager
310+
->expects(self::once())->method('updateUser')
311311
->with($user)
312312
;
313313

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

319-
$this->formFactory->expects(self::once())
320-
->method('create')
319+
$this->formFactory
320+
->expects(self::once())->method('create')
321321
->willReturn($form)
322322
;
323323

0 commit comments

Comments
 (0)