aboutsummaryrefslogtreecommitdiffstats
path: root/tests/Core/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Core/Controller')
-rw-r--r--tests/Core/Controller/AvatarControllerTest.php12
-rw-r--r--tests/Core/Controller/ChangePasswordControllerTest.php2
-rw-r--r--tests/Core/Controller/ClientFlowLoginControllerTest.php21
-rw-r--r--tests/Core/Controller/ClientFlowLoginV2ControllerTest.php14
-rw-r--r--tests/Core/Controller/LoginControllerTest.php8
-rw-r--r--tests/Core/Controller/LostControllerTest.php6
-rw-r--r--tests/Core/Controller/OCSControllerTest.php7
-rw-r--r--tests/Core/Controller/TwoFactorChallengeControllerTest.php4
8 files changed, 40 insertions, 34 deletions
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 c9ccf9ac674..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;
@@ -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());
@@ -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'));
}
@@ -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/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());
});