diff options
Diffstat (limited to 'tests/Core')
22 files changed, 80 insertions, 68 deletions
diff --git a/tests/Core/Command/Apps/AppsDisableTest.php b/tests/Core/Command/Apps/AppsDisableTest.php index ce43222e44e..283727c1a04 100644 --- a/tests/Core/Command/Apps/AppsDisableTest.php +++ b/tests/Core/Command/Apps/AppsDisableTest.php @@ -9,6 +9,8 @@ declare(strict_types=1); namespace Tests\Core\Command\Config; use OC\Core\Command\App\Disable; +use OCP\App\IAppManager; +use OCP\Server; use Symfony\Component\Console\Tester\CommandTester; use Test\TestCase; @@ -25,13 +27,13 @@ class AppsDisableTest extends TestCase { parent::setUp(); $command = new Disable( - \OC::$server->getAppManager() + Server::get(IAppManager::class) ); $this->commandTester = new CommandTester($command); - \OC::$server->getAppManager()->enableApp('admin_audit'); - \OC::$server->getAppManager()->enableApp('comments'); + Server::get(IAppManager::class)->enableApp('admin_audit'); + Server::get(IAppManager::class)->enableApp('comments'); } /** diff --git a/tests/Core/Command/Apps/AppsEnableTest.php b/tests/Core/Command/Apps/AppsEnableTest.php index 59b5dad6406..efaa7da984b 100644 --- a/tests/Core/Command/Apps/AppsEnableTest.php +++ b/tests/Core/Command/Apps/AppsEnableTest.php @@ -10,6 +10,9 @@ namespace Tests\Core\Command\Config; use OC\Core\Command\App\Enable; use OC\Installer; +use OCP\App\IAppManager; +use OCP\IGroupManager; +use OCP\Server; use Symfony\Component\Console\Tester\CommandTester; use Test\TestCase; @@ -26,15 +29,15 @@ class AppsEnableTest extends TestCase { parent::setUp(); $command = new Enable( - \OC::$server->getAppManager(), - \OC::$server->getGroupManager(), - \OC::$server->get(Installer::class), + Server::get(IAppManager::class), + Server::get(IGroupManager::class), + Server::get(Installer::class), ); $this->commandTester = new CommandTester($command); - \OC::$server->getAppManager()->disableApp('admin_audit'); - \OC::$server->getAppManager()->disableApp('comments'); + Server::get(IAppManager::class)->disableApp('admin_audit'); + Server::get(IAppManager::class)->disableApp('comments'); } /** diff --git a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php index 8232db70504..a2d1434e905 100644 --- a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php +++ b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php @@ -8,6 +8,7 @@ namespace Tests\Core\Command\Encryption; use OC\Core\Command\Encryption\ChangeKeyStorageRoot; +use OC\Encryption\Keys\Storage; use OC\Encryption\Util; use OC\Files\View; use OCP\IConfig; @@ -157,7 +158,7 @@ class ChangeKeyStorageRootTest extends TestCase { ->willReturn(true); $this->view->expects($this->once())->method('file_put_contents') - ->with('newRoot/' . \OC\Encryption\Keys\Storage::KEY_STORAGE_MARKER, + ->with('newRoot/' . Storage::KEY_STORAGE_MARKER, 'Nextcloud will detect this folder as key storage root only if this file exists')->willReturn(true); $this->invokePrivate($this->changeKeyStorageRoot, 'prepareNewRoot', ['newRoot']); diff --git a/tests/Core/Command/Encryption/DecryptAllTest.php b/tests/Core/Command/Encryption/DecryptAllTest.php index 45b331efb59..ea22c101845 100644 --- a/tests/Core/Command/Encryption/DecryptAllTest.php +++ b/tests/Core/Command/Encryption/DecryptAllTest.php @@ -79,7 +79,7 @@ class DecryptAllTest extends TestCase { ]; $this->config->expects($this->exactly(2)) ->method('setSystemValue') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -137,7 +137,7 @@ class DecryptAllTest extends TestCase { ]; $this->config->expects($this->exactly(2)) ->method('setAppValue') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -188,7 +188,7 @@ class DecryptAllTest extends TestCase { ]; $this->config->expects($this->exactly(2)) ->method('setAppValue') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -208,7 +208,7 @@ class DecryptAllTest extends TestCase { $this->decryptAll->expects($this->once()) ->method('decryptAll') ->with($this->consoleInput, $this->consoleOutput, 'user1') - ->willReturnCallback(function () { + ->willReturnCallback(function (): void { throw new \Exception(); }); diff --git a/tests/Core/Command/Encryption/SetDefaultModuleTest.php b/tests/Core/Command/Encryption/SetDefaultModuleTest.php index 52f14dd4537..4ba7b7e8c97 100644 --- a/tests/Core/Command/Encryption/SetDefaultModuleTest.php +++ b/tests/Core/Command/Encryption/SetDefaultModuleTest.php @@ -119,7 +119,7 @@ class SetDefaultModuleTest extends TestCase { ]; $this->consoleOutput->expects($this->exactly(2)) ->method('writeln') - ->willReturnCallback(function ($message) use (&$calls) { + ->willReturnCallback(function ($message) use (&$calls): void { $expected = array_shift($calls); $this->assertStringContainsString($expected, $message); }); diff --git a/tests/Core/Command/Log/FileTest.php b/tests/Core/Command/Log/FileTest.php index 1286fca35a3..627f2b0e08f 100644 --- a/tests/Core/Command/Log/FileTest.php +++ b/tests/Core/Command/Log/FileTest.php @@ -103,7 +103,7 @@ class FileTest extends TestCase { ]; $this->consoleOutput->expects($this->exactly(3)) ->method('writeln') - ->willReturnCallback(function (string $message) use (&$calls) { + ->willReturnCallback(function (string $message) use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected[0], $message); }); diff --git a/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php b/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php index 2f232837fe2..532e965cc89 100644 --- a/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php +++ b/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php @@ -65,7 +65,7 @@ class UpdateDBTest extends TestCase { ]; $this->consoleOutput->expects($this->exactly(2)) ->method('writeln') - ->willReturnCallback(function ($message) use (&$calls) { + ->willReturnCallback(function ($message) use (&$calls): void { $expected = array_shift($calls); $this->assertStringContainsString($expected, $message); }); @@ -110,7 +110,7 @@ class UpdateDBTest extends TestCase { ]; $this->consoleOutput->expects($this->exactly(4)) ->method('writeln') - ->willReturnCallback(function ($message) use (&$calls) { + ->willReturnCallback(function ($message) use (&$calls): void { $expected = array_shift($calls); $this->assertStringContainsString($expected, $message); }); @@ -163,7 +163,7 @@ class UpdateDBTest extends TestCase { ]; $this->consoleOutput->expects($this->exactly(3)) ->method('writeln') - ->willReturnCallback(function ($message) use (&$calls) { + ->willReturnCallback(function ($message) use (&$calls): void { $expected = array_shift($calls); $this->assertStringContainsString($expected, $message); }); diff --git a/tests/Core/Command/Preview/RepairTest.php b/tests/Core/Command/Preview/RepairTest.php index d522816e531..7e45a8d3a19 100644 --- a/tests/Core/Command/Preview/RepairTest.php +++ b/tests/Core/Command/Preview/RepairTest.php @@ -79,7 +79,7 @@ class RepairTest extends TestCase { ->willReturn($outputFormatter); $this->output->expects($this->any()) ->method('writeln') - ->willReturnCallback(function ($line) use ($self) { + ->willReturnCallback(function ($line) use ($self): void { $self->outputLines .= $line . "\n"; }); } diff --git a/tests/Core/Command/SystemTag/AddTest.php b/tests/Core/Command/SystemTag/AddTest.php index b697cd1d2f0..68d9b494502 100644 --- a/tests/Core/Command/SystemTag/AddTest.php +++ b/tests/Core/Command/SystemTag/AddTest.php @@ -93,7 +93,7 @@ class AddTest extends TestCase { $tag->method('getAccessLevel')->willReturn(ISystemTag::ACCESS_LEVEL_PUBLIC); $this->systemTagManager->method('createTag') - ->willReturnCallback(function ($tagName, $userVisible, $userAssignable) { + ->willReturnCallback(function ($tagName, $userVisible, $userAssignable): void { throw new TagAlreadyExistsException( 'Tag ("' . $tagName . '", ' . $userVisible . ', ' . $userAssignable . ') already exists' ); diff --git a/tests/Core/Command/SystemTag/DeleteTest.php b/tests/Core/Command/SystemTag/DeleteTest.php index 3c7a6e24c21..716b6a3b830 100644 --- a/tests/Core/Command/SystemTag/DeleteTest.php +++ b/tests/Core/Command/SystemTag/DeleteTest.php @@ -69,7 +69,7 @@ class DeleteTest extends TestCase { }); $this->systemTagManager->method('deleteTags') - ->willReturnCallback(function ($tagId) { + ->willReturnCallback(function ($tagId): void { throw new TagNotFoundException(); }); diff --git a/tests/Core/Command/SystemTag/EditTest.php b/tests/Core/Command/SystemTag/EditTest.php index 637172222eb..cc68f8004f5 100644 --- a/tests/Core/Command/SystemTag/EditTest.php +++ b/tests/Core/Command/SystemTag/EditTest.php @@ -134,7 +134,7 @@ class EditTest extends TestCase { }); $this->systemTagManager->method('updateTag') - ->willReturnCallback(function ($tagId, $tagName, $userVisible, $userAssignable) { + ->willReturnCallback(function ($tagId, $tagName, $userVisible, $userAssignable): void { throw new TagAlreadyExistsException( 'Tag ("' . $tagName . '", ' . $userVisible . ', ' . $userAssignable . ') already exists' ); diff --git a/tests/Core/Command/User/AddTest.php b/tests/Core/Command/User/AddTest.php index 91535ea6670..546061fc2f0 100644 --- a/tests/Core/Command/User/AddTest.php +++ b/tests/Core/Command/User/AddTest.php @@ -111,11 +111,11 @@ class AddTest extends TestCase { ->method('sendMail'); $this->consoleInput->method('getOption') - ->will(static::returnValueMap([ + ->willReturnMap([ ['generate-password', 'true'], ['email', $email], ['group', []], - ])); + ]); $this->invokePrivate($this->addCommand, 'execute', [ $this->consoleInput, diff --git a/tests/Core/Controller/AppPasswordControllerTest.php b/tests/Core/Controller/AppPasswordControllerTest.php index b33033edac3..eb1566eca8b 100644 --- a/tests/Core/Controller/AppPasswordControllerTest.php +++ b/tests/Core/Controller/AppPasswordControllerTest.php @@ -123,7 +123,7 @@ class AppPasswordControllerTest extends TestCase { $credentials->method('getLoginName') ->willReturn('myLoginName'); $this->request->method('getHeader') - ->with('USER_AGENT') + ->with('user-agent') ->willReturn('myUA'); $this->random->method('generate') ->with( @@ -164,7 +164,7 @@ class AppPasswordControllerTest extends TestCase { $credentials->method('getLoginName') ->willReturn('myLoginName'); $this->request->method('getHeader') - ->with('USER_AGENT') + ->with('user-agent') ->willReturn('myUA'); $this->random->method('generate') ->with( diff --git a/tests/Core/Controller/AvatarControllerTest.php b/tests/Core/Controller/AvatarControllerTest.php index 0dca611b020..4bda1713351 100644 --- a/tests/Core/Controller/AvatarControllerTest.php +++ b/tests/Core/Controller/AvatarControllerTest.php @@ -130,7 +130,7 @@ class AvatarControllerTest extends \Test\TestCase { */ public function testGetAvatarNoAvatar(): void { $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock); - $this->avatarMock->method('getFile')->will($this->throwException(new NotFoundException())); + $this->avatarMock->method('getFile')->willThrowException(new NotFoundException()); $response = $this->avatarController->getAvatar('userId', 32); //Comment out until JS is fixed @@ -183,7 +183,7 @@ class AvatarControllerTest extends \Test\TestCase { $this->avatarManager ->method('getAvatar') ->with('userDoesNotExist') - ->will($this->throwException(new \Exception('user does not exist'))); + ->willThrowException(new \Exception('user does not exist')); $response = $this->avatarController->getAvatar('userDoesNotExist', 32); @@ -287,7 +287,7 @@ class AvatarControllerTest extends \Test\TestCase { * Test what happens if the removing of the avatar fails */ public function testDeleteAvatarException(): void { - $this->avatarMock->method('remove')->will($this->throwException(new \Exception('foo'))); + $this->avatarMock->method('remove')->willThrowException(new \Exception('foo')); $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock); $this->logger->expects($this->once()) @@ -469,7 +469,7 @@ class AvatarControllerTest extends \Test\TestCase { public function testPostAvatarException(): void { $this->cache->expects($this->once()) ->method('set') - ->will($this->throwException(new \Exception('foo'))); + ->willThrowException(new \Exception('foo')); $file = $this->getMockBuilder('OCP\Files\File') ->disableOriginalConstructor()->getMock(); $file->expects($this->once()) @@ -514,7 +514,7 @@ class AvatarControllerTest extends \Test\TestCase { public function testPostCroppedAvatarNoSquareCrop(): void { $this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/testimage.jpg')); - $this->avatarMock->method('set')->will($this->throwException(new \OC\NotSquareException)); + $this->avatarMock->method('set')->willThrowException(new \OC\NotSquareException); $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock); $response = $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 11]); @@ -539,7 +539,7 @@ class AvatarControllerTest extends \Test\TestCase { public function testPostCroppedAvatarException(): void { $this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/testimage.jpg')); - $this->avatarMock->method('set')->will($this->throwException(new \Exception('foo'))); + $this->avatarMock->method('set')->willThrowException(new \Exception('foo')); $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock); $this->logger->expects($this->once()) diff --git a/tests/Core/Controller/ChangePasswordControllerTest.php b/tests/Core/Controller/ChangePasswordControllerTest.php index a806b091477..91d23c1104e 100644 --- a/tests/Core/Controller/ChangePasswordControllerTest.php +++ b/tests/Core/Controller/ChangePasswordControllerTest.php @@ -96,7 +96,7 @@ class ChangePasswordControllerTest extends \Test\TestCase { $user->expects($this->once()) ->method('setPassword') ->with('new') - ->will($this->throwException(new HintException('Common password'))); + ->willThrowException(new HintException('Common password')); $expects = new JSONResponse([ 'status' => 'error', diff --git a/tests/Core/Controller/ClientFlowLoginControllerTest.php b/tests/Core/Controller/ClientFlowLoginControllerTest.php index b10055ef542..34bfd104bdf 100644 --- a/tests/Core/Controller/ClientFlowLoginControllerTest.php +++ b/tests/Core/Controller/ClientFlowLoginControllerTest.php @@ -18,6 +18,9 @@ use OCA\OAuth2\Db\AccessTokenMapper; use OCA\OAuth2\Db\Client; use OCA\OAuth2\Db\ClientMapper; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\ContentSecurityPolicy; +use OCP\AppFramework\Http\RedirectResponse; +use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\StandaloneTemplateResponse; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Defaults; @@ -119,7 +122,7 @@ class ClientFlowLoginControllerTest extends TestCase { $this->request ->method('getHeader') ->willReturnMap([ - ['USER_AGENT', 'Mac OS X Sync Client'], + ['user-agent', 'Mac OS X Sync Client'], ['OCS-APIREQUEST', 'true'], ]); $this->random @@ -168,7 +171,7 @@ class ClientFlowLoginControllerTest extends TestCase { ], 'guest' ); - $csp = new Http\ContentSecurityPolicy(); + $csp = new ContentSecurityPolicy(); $csp->addAllowedFormActionDomain('nc://*'); $expected->setContentSecurityPolicy($csp); $this->assertEquals($expected, $this->clientFlowLoginController->showAuthPickerPage()); @@ -178,7 +181,7 @@ class ClientFlowLoginControllerTest extends TestCase { $this->request ->method('getHeader') ->willReturnMap([ - ['USER_AGENT', 'Mac OS X Sync Client'], + ['user-agent', 'Mac OS X Sync Client'], ['OCS-APIREQUEST', 'false'], ]); $client = new Client(); @@ -235,7 +238,7 @@ class ClientFlowLoginControllerTest extends TestCase { ], 'guest' ); - $csp = new Http\ContentSecurityPolicy(); + $csp = new ContentSecurityPolicy(); $csp->addAllowedFormActionDomain('https://example.com/redirect.php'); $expected->setContentSecurityPolicy($csp); $this->assertEquals($expected, $this->clientFlowLoginController->showAuthPickerPage('MyClientIdentifier')); @@ -279,7 +282,7 @@ class ClientFlowLoginControllerTest extends TestCase { ->method('getId') ->willThrowException(new SessionNotAvailableException()); - $expected = new Http\Response(); + $expected = new Response(); $expected->setStatus(Http::STATUS_FORBIDDEN); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); } @@ -304,7 +307,7 @@ class ClientFlowLoginControllerTest extends TestCase { ->with('SessionId') ->willThrowException(new InvalidTokenException()); - $expected = new Http\Response(); + $expected = new Response(); $expected->setStatus(Http::STATUS_FORBIDDEN); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); } @@ -380,7 +383,7 @@ class ClientFlowLoginControllerTest extends TestCase { $this->eventDispatcher->expects($this->once()) ->method('dispatchTyped'); - $expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken'); + $expected = new RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken'); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); } @@ -406,7 +409,7 @@ class ClientFlowLoginControllerTest extends TestCase { ]; $this->session ->method('remove') - ->willReturnCallback(function ($key) use (&$calls) { + ->willReturnCallback(function ($key) use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, $key); }); @@ -470,7 +473,7 @@ class ClientFlowLoginControllerTest extends TestCase { $this->eventDispatcher->expects($this->once()) ->method('dispatchTyped'); - $expected = new Http\RedirectResponse($redirectUrl); + $expected = new RedirectResponse($redirectUrl); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken', 'MyClientIdentifier')); } @@ -545,7 +548,7 @@ class ClientFlowLoginControllerTest extends TestCase { $this->eventDispatcher->expects($this->once()) ->method('dispatchTyped'); - $expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken'); + $expected = new RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken'); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); } @@ -555,7 +558,7 @@ class ClientFlowLoginControllerTest extends TestCase { [ ['X-Forwarded-Proto', 'http'], ['X-Forwarded-Ssl', 'off'], - ['USER_AGENT', ''], + ['user-agent', ''], ], 'http', 'http', @@ -564,7 +567,7 @@ class ClientFlowLoginControllerTest extends TestCase { [ ['X-Forwarded-Proto', 'http'], ['X-Forwarded-Ssl', 'off'], - ['USER_AGENT', ''], + ['user-agent', ''], ], 'https', 'https', @@ -573,7 +576,7 @@ class ClientFlowLoginControllerTest extends TestCase { [ ['X-Forwarded-Proto', 'https'], ['X-Forwarded-Ssl', 'off'], - ['USER_AGENT', ''], + ['user-agent', ''], ], 'http', 'https', @@ -582,7 +585,7 @@ class ClientFlowLoginControllerTest extends TestCase { [ ['X-Forwarded-Proto', 'https'], ['X-Forwarded-Ssl', 'on'], - ['USER_AGENT', ''], + ['user-agent', ''], ], 'http', 'https', @@ -591,7 +594,7 @@ class ClientFlowLoginControllerTest extends TestCase { [ ['X-Forwarded-Proto', 'http'], ['X-Forwarded-Ssl', 'on'], - ['USER_AGENT', ''], + ['user-agent', ''], ], 'http', 'https', @@ -676,7 +679,7 @@ class ClientFlowLoginControllerTest extends TestCase { $this->eventDispatcher->expects($this->once()) ->method('dispatchTyped'); - $expected = new Http\RedirectResponse('nc://login/server:' . $expected . '://example.com&user:MyLoginName&password:MyGeneratedToken'); + $expected = new RedirectResponse('nc://login/server:' . $expected . '://example.com&user:MyLoginName&password:MyGeneratedToken'); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); } } diff --git a/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php b/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php index 81de4cd92da..d130eb75c1a 100644 --- a/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php +++ b/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php @@ -15,6 +15,8 @@ use OC\Core\Exception\LoginFlowV2ClientForbiddenException; use OC\Core\Exception\LoginFlowV2NotFoundException; use OC\Core\Service\LoginFlowV2Service; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\RedirectResponse; +use OCP\AppFramework\Http\StandaloneTemplateResponse; use OCP\Defaults; use OCP\IL10N; use OCP\IRequest; @@ -111,7 +113,7 @@ class ClientFlowLoginV2ControllerTest extends TestCase { $result = $this->controller->landing('token'); $this->assertSame(Http::STATUS_FORBIDDEN, $result->getStatus()); - $this->assertInstanceOf(Http\StandaloneTemplateResponse::class, $result); + $this->assertInstanceOf(StandaloneTemplateResponse::class, $result); } public function testLandingValid(): void { @@ -129,7 +131,7 @@ class ClientFlowLoginV2ControllerTest extends TestCase { $result = $this->controller->landing('token'); - $this->assertInstanceOf(Http\RedirectResponse::class, $result); + $this->assertInstanceOf(RedirectResponse::class, $result); $this->assertSame(Http::STATUS_SEE_OTHER, $result->getStatus()); $this->assertSame('https://server/path', $result->getRedirectURL()); } @@ -168,7 +170,7 @@ class ClientFlowLoginV2ControllerTest extends TestCase { $result = $this->controller->showAuthPickerPage(); - $this->assertInstanceOf(Http\StandaloneTemplateResponse::class, $result); + $this->assertInstanceOf(StandaloneTemplateResponse::class, $result); $this->assertSame(Http::STATUS_FORBIDDEN, $result->getStatus()); $this->assertSame('Please use original client', $result->getParams()['message']); } @@ -247,7 +249,7 @@ class ClientFlowLoginV2ControllerTest extends TestCase { $result = $this->controller->grantPage('stateToken'); - $this->assertInstanceOf(Http\StandaloneTemplateResponse::class, $result); + $this->assertInstanceOf(StandaloneTemplateResponse::class, $result); $this->assertSame(Http::STATUS_FORBIDDEN, $result->getStatus()); $this->assertSame('Please use original client', $result->getParams()['message']); } @@ -330,7 +332,7 @@ class ClientFlowLoginV2ControllerTest extends TestCase { $result = $this->controller->generateAppPassword('stateToken'); - $this->assertInstanceOf(Http\StandaloneTemplateResponse::class, $result); + $this->assertInstanceOf(StandaloneTemplateResponse::class, $result); $this->assertSame(Http::STATUS_FORBIDDEN, $result->getStatus()); $this->assertSame('Please use original client', $result->getParams()['message']); } @@ -355,7 +357,7 @@ class ClientFlowLoginV2ControllerTest extends TestCase { $clearedState = false; $clearedLogin = false; $this->session->method('remove') - ->willReturnCallback(function ($name) use (&$clearedLogin, &$clearedState) { + ->willReturnCallback(function ($name) use (&$clearedLogin, &$clearedState): void { if ($name === 'client.flow.v2.state.token') { $clearedState = true; } diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php index d049203c302..6dcf4771f7e 100644 --- a/tests/Core/Controller/LoginControllerTest.php +++ b/tests/Core/Controller/LoginControllerTest.php @@ -279,7 +279,7 @@ class LoginControllerTest extends TestCase { ]; $this->initialState->expects($this->exactly(13)) ->method('provideInitialState') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); if (!empty($expected)) { $this->assertEquals($expected, func_get_args()); @@ -316,7 +316,7 @@ class LoginControllerTest extends TestCase { ]; $this->initialState->expects($this->exactly(14)) ->method('provideInitialState') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); if (!empty($expected)) { $this->assertEquals($expected, func_get_args()); @@ -396,7 +396,7 @@ class LoginControllerTest extends TestCase { ]; $this->initialState->expects($this->exactly(13)) ->method('provideInitialState') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); if (!empty($expected)) { $this->assertEquals($expected, func_get_args()); @@ -459,7 +459,7 @@ class LoginControllerTest extends TestCase { ]; $this->initialState->expects($this->exactly(13)) ->method('provideInitialState') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); if (!empty($expected)) { $this->assertEquals($expected, func_get_args()); diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php index ffe3eb3920d..e6d99a6523e 100644 --- a/tests/Core/Controller/LostControllerTest.php +++ b/tests/Core/Controller/LostControllerTest.php @@ -180,7 +180,7 @@ class LostControllerTest extends TestCase { $this->initialState ->expects($this->exactly(2)) ->method('provideInitialState') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -403,7 +403,7 @@ class LostControllerTest extends TestCase { ->expects($this->once()) ->method('send') ->with($message) - ->will($this->throwException(new \Exception())); + ->willThrowException(new \Exception()); $this->logger->expects($this->exactly(1)) ->method('error'); @@ -461,7 +461,7 @@ class LostControllerTest extends TestCase { $this->eventDispatcher ->expects($this->exactly(2)) ->method('dispatchTyped') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); diff --git a/tests/Core/Controller/OCSControllerTest.php b/tests/Core/Controller/OCSControllerTest.php index 142a15e2308..7e83a476744 100644 --- a/tests/Core/Controller/OCSControllerTest.php +++ b/tests/Core/Controller/OCSControllerTest.php @@ -15,6 +15,7 @@ use OCP\IRequest; use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; +use OCP\Server; use OCP\ServerVersion; use Test\TestCase; @@ -42,7 +43,7 @@ class OCSControllerTest extends TestCase { $this->userSession = $this->createMock(IUserSession::class); $this->userManager = $this->createMock(IUserManager::class); $this->keyManager = $this->createMock(Manager::class); - $serverVersion = \OCP\Server::get(ServerVersion::class); + $serverVersion = Server::get(ServerVersion::class); $this->controller = new OCSController( 'core', @@ -78,7 +79,7 @@ class OCSControllerTest extends TestCase { ->method('isLoggedIn') ->willReturn(true); - $serverVersion = \OCP\Server::get(ServerVersion::class); + $serverVersion = Server::get(ServerVersion::class); $result = []; $result['version'] = [ @@ -111,7 +112,7 @@ class OCSControllerTest extends TestCase { $this->userSession->expects($this->once()) ->method('isLoggedIn') ->willReturn(false); - $serverVersion = \OCP\Server::get(ServerVersion::class); + $serverVersion = Server::get(ServerVersion::class); $result = []; $result['version'] = [ diff --git a/tests/Core/Controller/PreviewControllerTest.php b/tests/Core/Controller/PreviewControllerTest.php index e7ecba27064..2c2411e666f 100644 --- a/tests/Core/Controller/PreviewControllerTest.php +++ b/tests/Core/Controller/PreviewControllerTest.php @@ -265,7 +265,7 @@ class PreviewControllerTest extends \Test\TestCase { $this->request ->method('getHeader') - ->with('X-NC-Preview') + ->with('x-nc-preview') ->willReturn('true'); $preview = $this->createMock(ISimpleFile::class); diff --git a/tests/Core/Controller/TwoFactorChallengeControllerTest.php b/tests/Core/Controller/TwoFactorChallengeControllerTest.php index 97900191199..d9ea1ca263f 100644 --- a/tests/Core/Controller/TwoFactorChallengeControllerTest.php +++ b/tests/Core/Controller/TwoFactorChallengeControllerTest.php @@ -301,14 +301,14 @@ class TwoFactorChallengeControllerTest extends TestCase { $this->twoFactorManager->expects($this->once()) ->method('verifyChallenge') ->with('myprovider', $user, 'token') - ->will($this->throwException($exception)); + ->willThrowException($exception); $calls = [ ['two_factor_auth_error_message', '2FA failed'], ['two_factor_auth_error', true], ]; $this->session->expects($this->exactly(2)) ->method('set') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); |