Merge pull request #32572 from nextcloud/phpunit-deprecation-core

Fix a bunch of deprecation in the phpunit for core
This commit is contained in:
Côme Chilliet 2023-01-24 11:28:19 +01:00 committed by GitHub
commit 486e1dff40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 62 additions and 58 deletions

View File

@ -30,8 +30,13 @@ if [ -z "$PHP_EXE" ]; then
fi fi
PHP=$(which "$PHP_EXE") PHP=$(which "$PHP_EXE")
if [ -z "$PHPUNIT_EXE" ]; then if [ -z "$PHPUNIT_EXE" ]; then
PHPUNIT_EXE=phpunit if [ -f "build/integration/vendor/bin/phpunit" ]; then
PHPUNIT_EXE="./build/integration/vendor/bin/phpunit"
else
PHPUNIT_EXE=phpunit
fi
fi fi
PHPUNIT=$(which "$PHPUNIT_EXE") PHPUNIT=$(which "$PHPUNIT_EXE")
set -e set -e
@ -56,7 +61,7 @@ else
fi fi
if ! [ -x "$PHPUNIT" ]; then if ! [ -x "$PHPUNIT" ]; then
echo "phpunit executable not found, please install phpunit version >= 6.5" >&2 echo "phpunit executable not found, please install phpunit version >= 9.0" >&2
exit 3 exit 3
fi fi

View File

@ -61,7 +61,7 @@ class AppsDisableTest extends TestCase {
$this->commandTester->execute($input); $this->commandTester->execute($input);
$this->assertRegExp('/' . $pattern . '/', $this->commandTester->getDisplay()); $this->assertMatchesRegularExpression('/' . $pattern . '/', $this->commandTester->getDisplay());
$this->assertSame($statusCode, $this->commandTester->getStatusCode()); $this->assertSame($statusCode, $this->commandTester->getStatusCode());
} }

View File

@ -66,7 +66,7 @@ class AppsEnableTest extends TestCase {
$this->commandTester->execute($input); $this->commandTester->execute($input);
$this->assertRegExp('/' . $pattern . '/', $this->commandTester->getDisplay()); $this->assertMatchesRegularExpression('/' . $pattern . '/', $this->commandTester->getDisplay());
$this->assertSame($statusCode, $this->commandTester->getStatusCode()); $this->assertSame($statusCode, $this->commandTester->getStatusCode());
} }

View File

@ -249,27 +249,30 @@ class LoginControllerTest extends TestCase {
], ],
] ]
); );
$this->initialStateService->expects($this->at(0)) $this->initialStateService->expects($this->exactly(11))
->method('provideInitialState') ->method('provideInitialState')
->with( ->withConsecutive([
'core', 'core',
'loginMessages', 'loginMessages',
[ [
'MessageArray1', 'MessageArray1',
'MessageArray2', 'MessageArray2',
'This community release of Nextcloud is unsupported and push notifications are limited.', 'This community release of Nextcloud is unsupported and push notifications are limited.',
] ],
); ],
$this->initialStateService->expects($this->at(1))
->method('provideInitialState')
->with(
'core',
'loginErrors',
[ [
'ErrorArray1', 'core',
'ErrorArray2', 'loginErrors',
] [
); 'ErrorArray1',
'ErrorArray2',
],
],
[
'core',
'loginUsername',
'',
]);
$expectedResponse = new TemplateResponse( $expectedResponse = new TemplateResponse(
'core', 'core',
@ -288,13 +291,17 @@ class LoginControllerTest extends TestCase {
->expects($this->once()) ->expects($this->once())
->method('isLoggedIn') ->method('isLoggedIn')
->willReturn(false); ->willReturn(false);
$this->initialStateService->expects($this->at(4)) $this->initialStateService->expects($this->exactly(12))
->method('provideInitialState') ->method('provideInitialState')
->with( ->withConsecutive([], [], [], [
'core',
'loginAutocomplete',
false
], [
'core', 'core',
'loginRedirectUrl', 'loginRedirectUrl',
'login/flow' 'login/flow'
); ]);
$expectedResponse = new TemplateResponse( $expectedResponse = new TemplateResponse(
'core', 'core',
@ -355,20 +362,17 @@ class LoginControllerTest extends TestCase {
->method('get') ->method('get')
->with('LdapUser') ->with('LdapUser')
->willReturn($user); ->willReturn($user);
$this->initialStateService->expects($this->at(2)) $this->initialStateService->expects($this->exactly(11))
->method('provideInitialState') ->method('provideInitialState')
->with( ->withConsecutive([], [], [
'core', 'core',
'loginUsername', 'loginUsername',
'LdapUser' 'LdapUser'
); ], [], [], [], [
$this->initialStateService->expects($this->at(6))
->method('provideInitialState')
->with(
'core', 'core',
'loginCanResetPassword', 'loginCanResetPassword',
$expectedResult $expectedResult
); ]);
$expectedResponse = new TemplateResponse( $expectedResponse = new TemplateResponse(
'core', 'core',
@ -408,27 +412,21 @@ class LoginControllerTest extends TestCase {
->method('get') ->method('get')
->with('0') ->with('0')
->willReturn($user); ->willReturn($user);
$this->initialStateService->expects($this->at(3)) $this->initialStateService->expects($this->exactly(11))
->method('provideInitialState') ->method('provideInitialState')
->with( ->withConsecutive([], [], [], [
'core', 'core',
'loginAutocomplete', 'loginAutocomplete',
true true
); ], [], [
$this->initialStateService->expects($this->at(5))
->method('provideInitialState')
->with(
'core', 'core',
'loginResetPasswordLink', 'loginResetPasswordLink',
false false
); ], [
$this->initialStateService->expects($this->at(6))
->method('provideInitialState')
->with(
'core', 'core',
'loginCanResetPassword', 'loginCanResetPassword',
false false
); ]);
$expectedResponse = new TemplateResponse( $expectedResponse = new TemplateResponse(
'core', 'core',

View File

@ -74,14 +74,13 @@ class NavigationControllerTest extends TestCase {
$this->urlGenerator->expects($this->any()) $this->urlGenerator->expects($this->any())
->method('getBaseURL') ->method('getBaseURL')
->willReturn('http://localhost/'); ->willReturn('http://localhost/');
$this->urlGenerator->expects($this->at(1)) $this->urlGenerator->expects($this->exactly(2))
->method('getAbsoluteURL') ->method('getAbsoluteURL')
->with('/index.php/apps/files') ->withConsecutive(['/index.php/apps/files'], ['icon'])
->willReturn('http://localhost/index.php/apps/files'); ->willReturnOnConsecutiveCalls(
$this->urlGenerator->expects($this->at(3)) 'http://localhost/index.php/apps/files',
->method('getAbsoluteURL') 'http://localhost/icon'
->with('icon') );
->willReturn('http://localhost/icon');
$actual = $this->controller->getAppsNavigation($absolute); $actual = $this->controller->getAppsNavigation($absolute);
$this->assertInstanceOf(DataResponse::class, $actual); $this->assertInstanceOf(DataResponse::class, $actual);
$this->assertEquals('http://localhost/index.php/apps/files', $actual->getData()[0]['href']); $this->assertEquals('http://localhost/index.php/apps/files', $actual->getData()[0]['href']);
@ -104,14 +103,16 @@ class NavigationControllerTest extends TestCase {
$this->urlGenerator->expects($this->any()) $this->urlGenerator->expects($this->any())
->method('getBaseURL') ->method('getBaseURL')
->willReturn('http://localhost/'); ->willReturn('http://localhost/');
$this->urlGenerator->expects($this->at(1)) $this->urlGenerator->expects($this->exactly(2))
->method('getAbsoluteURL') ->method('getAbsoluteURL')
->with('/index.php/settings/user') ->withConsecutive(
->willReturn('http://localhost/index.php/settings/user'); ['/index.php/settings/user'],
$this->urlGenerator->expects($this->at(3)) ['/core/img/settings.svg']
->method('getAbsoluteURL') )
->with('/core/img/settings.svg') ->willReturnOnConsecutiveCalls(
->willReturn('http://localhost/core/img/settings.svg'); 'http://localhost/index.php/settings/user',
'http://localhost/core/img/settings.svg'
);
$actual = $this->controller->getSettingsNavigation($absolute); $actual = $this->controller->getSettingsNavigation($absolute);
$this->assertInstanceOf(DataResponse::class, $actual); $this->assertInstanceOf(DataResponse::class, $actual);
$this->assertEquals('http://localhost/index.php/settings/user', $actual->getData()[0]['href']); $this->assertEquals('http://localhost/index.php/settings/user', $actual->getData()[0]['href']);

View File

@ -316,12 +316,12 @@ class TwoFactorChallengeControllerTest extends TestCase {
->method('verifyChallenge') ->method('verifyChallenge')
->with('myprovider', $user, 'token') ->with('myprovider', $user, 'token')
->will($this->throwException($exception)); ->will($this->throwException($exception));
$this->session->expects($this->at(0)) $this->session->expects($this->exactly(2))
->method('set') ->method('set')
->with('two_factor_auth_error_message', "2FA failed"); ->withConsecutive(
$this->session->expects($this->at(1)) ['two_factor_auth_error_message', '2FA failed'],
->method('set') ['two_factor_auth_error', true]
->with('two_factor_auth_error', true); );
$this->urlGenerator->expects($this->once()) $this->urlGenerator->expects($this->once())
->method('linkToRoute') ->method('linkToRoute')
->with('core.TwoFactorChallenge.showChallenge', [ ->with('core.TwoFactorChallenge.showChallenge', [

View File

@ -350,7 +350,7 @@ class LoginFlowV2ServiceUnitTest extends TestCase {
// app password is encrypted and must look like: // app password is encrypted and must look like:
// ZACZOOzxTpKz4+KXL5kZ/gCK0xvkaVi/8yzupAn6Ui6+5qCSKvfPKGgeDRKs0sivvSLzk/XSp811SZCZmH0Y3g== // ZACZOOzxTpKz4+KXL5kZ/gCK0xvkaVi/8yzupAn6Ui6+5qCSKvfPKGgeDRKs0sivvSLzk/XSp811SZCZmH0Y3g==
$this->assertRegExp('/[a-zA-Z\/0-9+=]+/', $loginFlowV2->getAppPassword()); $this->assertMatchesRegularExpression('/[a-zA-Z\/0-9+=]+/', $loginFlowV2->getAppPassword());
$this->assertEquals('server', $loginFlowV2->getServer()); $this->assertEquals('server', $loginFlowV2->getServer());
} }