Skip to content

Commit 1cb612a

Browse files
committed
Fix a bunch of deprecation in the phpunit for core
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent 95f390d commit 1cb612a

6 files changed

Lines changed: 51 additions & 52 deletions

File tree

tests/Core/Command/Apps/AppsDisableTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testCommandInput($appId, $statusCode, $pattern): void {
6262

6363
$this->commandTester->execute($input);
6464

65-
$this->assertRegExp('/' . $pattern . '/', $this->commandTester->getDisplay());
65+
$this->assertMatchesRegularExpression('/' . $pattern . '/', $this->commandTester->getDisplay());
6666
$this->assertSame($statusCode, $this->commandTester->getStatusCode());
6767
}
6868

tests/Core/Command/Apps/AppsEnableTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testCommandInput($appId, $groups, $statusCode, $pattern): void {
6767

6868
$this->commandTester->execute($input);
6969

70-
$this->assertRegExp('/' . $pattern . '/', $this->commandTester->getDisplay());
70+
$this->assertMatchesRegularExpression('/' . $pattern . '/', $this->commandTester->getDisplay());
7171
$this->assertSame($statusCode, $this->commandTester->getStatusCode());
7272
}
7373

tests/Core/Controller/LoginControllerTest.php

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -258,27 +258,30 @@ public function testShowLoginFormWithErrorsInSession() {
258258
],
259259
]
260260
);
261-
$this->initialStateService->expects($this->at(0))
261+
$this->initialStateService->expects($this->exactly(10))
262262
->method('provideInitialState')
263-
->with(
263+
->withConsecutive([
264264
'core',
265265
'loginMessages',
266266
[
267267
'MessageArray1',
268268
'MessageArray2',
269269
'This community release of Nextcloud is unsupported and instant notifications are unavailable.',
270-
]
271-
);
272-
$this->initialStateService->expects($this->at(1))
273-
->method('provideInitialState')
274-
->with(
270+
],
271+
],
272+
[
275273
'core',
276274
'loginErrors',
277275
[
278276
'ErrorArray1',
279277
'ErrorArray2',
280-
]
281-
);
278+
],
279+
],
280+
[
281+
'core',
282+
'loginUsername',
283+
'',
284+
]);
282285

283286
$expectedResponse = new TemplateResponse(
284287
'core',
@@ -296,13 +299,17 @@ public function testShowLoginFormForFlowAuth() {
296299
->expects($this->once())
297300
->method('isLoggedIn')
298301
->willReturn(false);
299-
$this->initialStateService->expects($this->at(4))
302+
$this->initialStateService->expects($this->exactly(11))
300303
->method('provideInitialState')
301-
->with(
304+
->withConsecutive([], [], [], [
305+
'core',
306+
'loginAutocomplete',
307+
false
308+
], [
302309
'core',
303310
'loginRedirectUrl',
304311
'login/flow'
305-
);
312+
]);
306313

307314
$expectedResponse = new TemplateResponse(
308315
'core',
@@ -357,20 +364,17 @@ public function testShowLoginFormWithPasswordResetOption($canChangePassword,
357364
->method('get')
358365
->with('LdapUser')
359366
->willReturn($user);
360-
$this->initialStateService->expects($this->at(2))
367+
$this->initialStateService->expects($this->exactly(10))
361368
->method('provideInitialState')
362-
->with(
369+
->withConsecutive([], [], [
363370
'core',
364371
'loginUsername',
365372
'LdapUser'
366-
);
367-
$this->initialStateService->expects($this->at(6))
368-
->method('provideInitialState')
369-
->with(
373+
], [], [], [], [
370374
'core',
371375
'loginCanResetPassword',
372376
$expectedResult
373-
);
377+
]);
374378

375379
$expectedResponse = new TemplateResponse(
376380
'core',
@@ -404,27 +408,21 @@ public function testShowLoginFormForUserNamed0() {
404408
->method('get')
405409
->with('0')
406410
->willReturn($user);
407-
$this->initialStateService->expects($this->at(3))
411+
$this->initialStateService->expects($this->exactly(10))
408412
->method('provideInitialState')
409-
->with(
413+
->withConsecutive([], [], [], [
410414
'core',
411415
'loginAutocomplete',
412416
true
413-
);
414-
$this->initialStateService->expects($this->at(5))
415-
->method('provideInitialState')
416-
->with(
417+
], [], [
417418
'core',
418419
'loginResetPasswordLink',
419420
false
420-
);
421-
$this->initialStateService->expects($this->at(6))
422-
->method('provideInitialState')
423-
->with(
421+
], [
424422
'core',
425423
'loginCanResetPassword',
426424
false
427-
);
425+
]);
428426

429427
$expectedResponse = new TemplateResponse(
430428
'core',

tests/Core/Controller/NavigationControllerTest.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,13 @@ public function testGetAppNavigation($absolute) {
7575
$this->urlGenerator->expects($this->any())
7676
->method('getBaseURL')
7777
->willReturn('http://localhost/');
78-
$this->urlGenerator->expects($this->at(1))
78+
$this->urlGenerator->expects($this->exactly(2))
7979
->method('getAbsoluteURL')
80-
->with('/index.php/apps/files')
81-
->willReturn('http://localhost/index.php/apps/files');
82-
$this->urlGenerator->expects($this->at(3))
83-
->method('getAbsoluteURL')
84-
->with('icon')
85-
->willReturn('http://localhost/icon');
80+
->withConsecutive(['/index.php/apps/files'], ['icon'])
81+
->willReturnOnConsecutiveCalls(
82+
'http://localhost/index.php/apps/files',
83+
'http://localhost/icon'
84+
);
8685
$actual = $this->controller->getAppsNavigation($absolute);
8786
$this->assertInstanceOf(DataResponse::class, $actual);
8887
$this->assertEquals('http://localhost/index.php/apps/files', $actual->getData()[0]['href']);
@@ -105,14 +104,16 @@ public function testGetSettingsNavigation($absolute) {
105104
$this->urlGenerator->expects($this->any())
106105
->method('getBaseURL')
107106
->willReturn('http://localhost/');
108-
$this->urlGenerator->expects($this->at(1))
109-
->method('getAbsoluteURL')
110-
->with('/index.php/settings/user')
111-
->willReturn('http://localhost/index.php/settings/user');
112-
$this->urlGenerator->expects($this->at(3))
107+
$this->urlGenerator->expects($this->exactly(2))
113108
->method('getAbsoluteURL')
114-
->with('/core/img/settings.svg')
115-
->willReturn('http://localhost/core/img/settings.svg');
109+
->withConsecutive(
110+
['/index.php/settings/user'],
111+
['/core/img/settings.svg']
112+
)
113+
->willReturnOnConsecutiveCalls(
114+
'http://localhost/index.php/settings/user',
115+
'http://localhost/core/img/settings.svg'
116+
);
116117
$actual = $this->controller->getSettingsNavigation($absolute);
117118
$this->assertInstanceOf(DataResponse::class, $actual);
118119
$this->assertEquals('http://localhost/index.php/settings/user', $actual->getData()[0]['href']);

tests/Core/Controller/TwoFactorChallengeControllerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,12 @@ public function testSolveChallengeTwoFactorException() {
317317
->method('verifyChallenge')
318318
->with('myprovider', $user, 'token')
319319
->will($this->throwException($exception));
320-
$this->session->expects($this->at(0))
321-
->method('set')
322-
->with('two_factor_auth_error_message', "2FA failed");
323-
$this->session->expects($this->at(1))
320+
$this->session->expects($this->exactly(2))
324321
->method('set')
325-
->with('two_factor_auth_error', true);
322+
->withConsecutive(
323+
['two_factor_auth_error_message', '2FA failed'],
324+
['two_factor_auth_error', true]
325+
);
326326
$this->urlGenerator->expects($this->once())
327327
->method('linkToRoute')
328328
->with('core.TwoFactorChallenge.showChallenge', [

tests/Core/Service/LoginFlowV2ServiceUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ public function testFlowDone() {
349349

350350
// app password is encrypted and must look like:
351351
// ZACZOOzxTpKz4+KXL5kZ/gCK0xvkaVi/8yzupAn6Ui6+5qCSKvfPKGgeDRKs0sivvSLzk/XSp811SZCZmH0Y3g==
352-
$this->assertRegExp('/[a-zA-Z\/0-9+=]+/', $loginFlowV2->getAppPassword());
352+
$this->assertMatchesRegularExpression('/[a-zA-Z\/0-9+=]+/', $loginFlowV2->getAppPassword());
353353

354354
$this->assertEquals('server', $loginFlowV2->getServer());
355355
}

0 commit comments

Comments
 (0)