diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-27 15:27:18 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-27 15:27:18 +0100 |
commit | 3a7cf40aaa678bea1df143d2982d603b7a334eec (patch) | |
tree | 63c1e3ad7f7f401d14411a4d44c523632906afc9 /tests/Core | |
parent | 0568b012672d650c6b5a49e72c4028dde5463c60 (diff) | |
download | nextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.tar.gz nextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.zip |
Mode to modern phpunit
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests/Core')
28 files changed, 57 insertions, 54 deletions
diff --git a/tests/Core/Command/Apps/AppsDisableTest.php b/tests/Core/Command/Apps/AppsDisableTest.php index f066eaba401..cbe6a816cd6 100644 --- a/tests/Core/Command/Apps/AppsDisableTest.php +++ b/tests/Core/Command/Apps/AppsDisableTest.php @@ -36,7 +36,7 @@ class AppsDisableTest extends TestCase { /** @var CommandTester */ private $commandTester; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $command = new Disable( diff --git a/tests/Core/Command/Apps/AppsEnableTest.php b/tests/Core/Command/Apps/AppsEnableTest.php index a30bef59326..6c137dca44b 100644 --- a/tests/Core/Command/Apps/AppsEnableTest.php +++ b/tests/Core/Command/Apps/AppsEnableTest.php @@ -36,7 +36,7 @@ class AppsEnableTest extends TestCase { /** @var CommandTester */ private $commandTester; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $command = new Enable( diff --git a/tests/Core/Command/Config/System/SetConfigTest.php b/tests/Core/Command/Config/System/SetConfigTest.php index e3cfa89093d..9b34afed691 100644 --- a/tests/Core/Command/Config/System/SetConfigTest.php +++ b/tests/Core/Command/Config/System/SetConfigTest.php @@ -102,9 +102,10 @@ class SetConfigTest extends TestCase { /** * @dataProvider setUpdateOnlyProvider - * @expectedException \UnexpectedValueException */ public function testSetUpdateOnly($configNames, $existingData) { + $this->expectException(\UnexpectedValueException::class); + $this->systemConfig->expects($this->never()) ->method('setValue'); $this->systemConfig->method('getValue') @@ -169,9 +170,10 @@ class SetConfigTest extends TestCase { /** * @dataProvider castValueInvalidProvider - * @expectedException \InvalidArgumentException */ public function testCastValueInvalid($value, $type) { + $this->expectException(\InvalidArgumentException::class); + $this->invokePrivate($this->command, 'castValue', [$value, $type]); } diff --git a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php index 0f56cf53fa8..d17050e7245 100644 --- a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php +++ b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php @@ -63,7 +63,7 @@ class ChangeKeyStorageRootTest extends TestCase { /** @var \OCP\UserInterface | \PHPUnit_Framework_MockObject_MockObject */ protected $userInterface; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->view = $this->getMockBuilder(View::class)->getMock(); @@ -181,12 +181,13 @@ class ChangeKeyStorageRootTest extends TestCase { /** * @dataProvider dataTestPrepareNewRootException - * @expectedException \Exception * * @param bool $dirExists * @param bool $couldCreateFile */ public function testPrepareNewRootException($dirExists, $couldCreateFile) { + $this->expectException(\Exception::class); + $this->view->expects($this->once())->method('is_dir')->with('newRoot') ->willReturn($dirExists); $this->view->expects($this->any())->method('file_put_contents')->willReturn($couldCreateFile); @@ -370,10 +371,10 @@ class ChangeKeyStorageRootTest extends TestCase { ); } - /** - * @expectedException \Exception - */ + public function testTargetExistsException() { + $this->expectException(\Exception::class); + $this->view->expects($this->once())->method('file_exists')->with('path') ->willReturn(true); diff --git a/tests/Core/Command/Encryption/DecryptAllTest.php b/tests/Core/Command/Encryption/DecryptAllTest.php index 7fa95351045..acdaff4bbab 100644 --- a/tests/Core/Command/Encryption/DecryptAllTest.php +++ b/tests/Core/Command/Encryption/DecryptAllTest.php @@ -54,7 +54,7 @@ class DecryptAllTest extends TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject | \OC\Encryption\DecryptAll */ protected $decryptAll; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->config = $this->getMockBuilder(IConfig::class) @@ -181,10 +181,10 @@ class DecryptAllTest extends TestCase { ]; } - /** - * @expectedException \Exception - */ + public function testExecuteFailure() { + $this->expectException(\Exception::class); + $instance = new DecryptAll( $this->encryptionManager, $this->appManager, diff --git a/tests/Core/Command/Encryption/EncryptAllTest.php b/tests/Core/Command/Encryption/EncryptAllTest.php index 9c9818475f5..778d51fd8b8 100644 --- a/tests/Core/Command/Encryption/EncryptAllTest.php +++ b/tests/Core/Command/Encryption/EncryptAllTest.php @@ -128,10 +128,10 @@ class EncryptAllTest extends TestCase { ]; } - /** - * @expectedException \Exception - */ + public function testExecuteException() { + $this->expectException(\Exception::class); + $command = new EncryptAll($this->encryptionManager, $this->appManager, $this->config, $this->questionHelper); $this->encryptionManager->expects($this->once())->method('isEnabled')->willReturn(false); $this->encryptionManager->expects($this->never())->method('getEncryptionModule'); diff --git a/tests/Core/Command/Group/AddTest.php b/tests/Core/Command/Group/AddTest.php index ea30a5d3d68..d4ba34246af 100644 --- a/tests/Core/Command/Group/AddTest.php +++ b/tests/Core/Command/Group/AddTest.php @@ -44,7 +44,7 @@ class AddTest extends TestCase { /** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */ private $output; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->groupManager = $this->createMock(IGroupManager::class); diff --git a/tests/Core/Command/Group/AddUserTest.php b/tests/Core/Command/Group/AddUserTest.php index 85288d9e29c..1ee2d2d3377 100644 --- a/tests/Core/Command/Group/AddUserTest.php +++ b/tests/Core/Command/Group/AddUserTest.php @@ -49,7 +49,7 @@ class AddUserTest extends TestCase { /** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */ private $output; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->groupManager = $this->createMock(IGroupManager::class); diff --git a/tests/Core/Command/Group/DeleteTest.php b/tests/Core/Command/Group/DeleteTest.php index 4c2acbbad94..69bdae99d63 100644 --- a/tests/Core/Command/Group/DeleteTest.php +++ b/tests/Core/Command/Group/DeleteTest.php @@ -44,7 +44,7 @@ class DeleteTest extends TestCase { /** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */ private $output; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->groupManager = $this->createMock(IGroupManager::class); diff --git a/tests/Core/Command/Group/ListCommandTest.php b/tests/Core/Command/Group/ListCommandTest.php index 71697d89401..21adb29924a 100644 --- a/tests/Core/Command/Group/ListCommandTest.php +++ b/tests/Core/Command/Group/ListCommandTest.php @@ -45,7 +45,7 @@ class ListCommandTest extends TestCase { /** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */ private $output; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->groupManager = $this->createMock(IGroupManager::class); diff --git a/tests/Core/Command/Group/RemoveUserTest.php b/tests/Core/Command/Group/RemoveUserTest.php index 7e835f58478..eda4886da3b 100644 --- a/tests/Core/Command/Group/RemoveUserTest.php +++ b/tests/Core/Command/Group/RemoveUserTest.php @@ -49,7 +49,7 @@ class RemoveUserTest extends TestCase { /** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */ private $output; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->groupManager = $this->createMock(IGroupManager::class); diff --git a/tests/Core/Command/Log/ManageTest.php b/tests/Core/Command/Log/ManageTest.php index 92907948fb2..d73bc7ed9c2 100644 --- a/tests/Core/Command/Log/ManageTest.php +++ b/tests/Core/Command/Log/ManageTest.php @@ -87,17 +87,17 @@ class ManageTest extends TestCase { self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); } - /** - * @expectedException \InvalidArgumentException - */ + public function testValidateBackend() { + $this->expectException(\InvalidArgumentException::class); + self::invokePrivate($this->command, 'validateBackend', ['notabackend']); } - /** - * @expectedException \Exception - */ + public function testValidateTimezone() { + $this->expectException(\Exception::class); + // this might need to be changed when humanity colonises Mars self::invokePrivate($this->command, 'validateTimezone', ['Mars/OlympusMons']); } @@ -123,10 +123,10 @@ class ManageTest extends TestCase { ); } - /** - * @expectedException \InvalidArgumentException - */ + public function testConvertLevelStringInvalid() { + $this->expectException(\InvalidArgumentException::class); + self::invokePrivate($this->command, 'convertLevelString', ['abc']); } @@ -149,10 +149,10 @@ class ManageTest extends TestCase { ); } - /** - * @expectedException \InvalidArgumentException - */ + public function testConvertLevelNumberInvalid() { + $this->expectException(\InvalidArgumentException::class); + self::invokePrivate($this->command, 'convertLevelNumber', [11]); } diff --git a/tests/Core/Command/TwoFactorAuth/DisableTest.php b/tests/Core/Command/TwoFactorAuth/DisableTest.php index 9741f5b2b52..fc0def50b90 100644 --- a/tests/Core/Command/TwoFactorAuth/DisableTest.php +++ b/tests/Core/Command/TwoFactorAuth/DisableTest.php @@ -45,7 +45,7 @@ class DisableTest extends TestCase { /** @var CommandTester */ private $command; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->providerManager = $this->createMock(ProviderManager::class); diff --git a/tests/Core/Command/TwoFactorAuth/EnableTest.php b/tests/Core/Command/TwoFactorAuth/EnableTest.php index bd74bde2e81..faf00ed1ded 100644 --- a/tests/Core/Command/TwoFactorAuth/EnableTest.php +++ b/tests/Core/Command/TwoFactorAuth/EnableTest.php @@ -45,7 +45,7 @@ class EnableTest extends TestCase { /** @var CommandTester */ private $command; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->providerManager = $this->createMock(ProviderManager::class); diff --git a/tests/Core/Controller/AppPasswordControllerTest.php b/tests/Core/Controller/AppPasswordControllerTest.php index 00a4dd2b5fa..ceccf912285 100644 --- a/tests/Core/Controller/AppPasswordControllerTest.php +++ b/tests/Core/Controller/AppPasswordControllerTest.php @@ -64,7 +64,7 @@ class AppPasswordControllerTest extends TestCase { /** @var AppPasswordController */ private $controller; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->session = $this->createMock(ISession::class); diff --git a/tests/Core/Controller/AvatarControllerTest.php b/tests/Core/Controller/AvatarControllerTest.php index d7feec28fd2..9135a6bc92f 100644 --- a/tests/Core/Controller/AvatarControllerTest.php +++ b/tests/Core/Controller/AvatarControllerTest.php @@ -121,7 +121,7 @@ class AvatarControllerTest extends \Test\TestCase { $this->avatarFile->method('getEtag')->willReturn('my etag'); } - public function tearDown(): void { + protected function tearDown(): void { parent::tearDown(); } diff --git a/tests/Core/Controller/ChangePasswordControllerTest.php b/tests/Core/Controller/ChangePasswordControllerTest.php index ac9d9d37993..a55b0bc232e 100644 --- a/tests/Core/Controller/ChangePasswordControllerTest.php +++ b/tests/Core/Controller/ChangePasswordControllerTest.php @@ -49,7 +49,7 @@ class ChangePasswordControllerTest extends \Test\TestCase { /** @var ChangePasswordController */ private $controller; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->userManager = $this->createMock(\OC\User\Manager::class); diff --git a/tests/Core/Controller/ClientFlowLoginControllerTest.php b/tests/Core/Controller/ClientFlowLoginControllerTest.php index ebe43ba560f..3932cb9e144 100644 --- a/tests/Core/Controller/ClientFlowLoginControllerTest.php +++ b/tests/Core/Controller/ClientFlowLoginControllerTest.php @@ -74,7 +74,7 @@ class ClientFlowLoginControllerTest extends TestCase { /** @var ClientFlowLoginController */ private $clientFlowLoginController; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->request = $this->createMock(IRequest::class); diff --git a/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php b/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php index d8ce67b18f1..3c39a402f55 100644 --- a/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php +++ b/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php @@ -58,7 +58,7 @@ class ClientFlowLoginV2ControllerTest extends TestCase { /** @var ClientFlowLoginV2Controller */ private $controller; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->request = $this->createMock(IRequest::class); diff --git a/tests/Core/Controller/CssControllerTest.php b/tests/Core/Controller/CssControllerTest.php index edee29cee57..c0d1ea42f41 100644 --- a/tests/Core/Controller/CssControllerTest.php +++ b/tests/Core/Controller/CssControllerTest.php @@ -48,7 +48,7 @@ class CssControllerTest extends TestCase { /** @var CssController */ private $controller; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); /** @var Factory|\PHPUnit_Framework_MockObject_MockObject $factory */ diff --git a/tests/Core/Controller/JsControllerTest.php b/tests/Core/Controller/JsControllerTest.php index 503e97d1c53..26df6d181ef 100644 --- a/tests/Core/Controller/JsControllerTest.php +++ b/tests/Core/Controller/JsControllerTest.php @@ -48,7 +48,7 @@ class JsControllerTest extends TestCase { /** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */ private $request; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); /** @var Factory|\PHPUnit_Framework_MockObject_MockObject $factory */ diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php index 6a8db74b0d3..b4f3663c0ba 100644 --- a/tests/Core/Controller/LoginControllerTest.php +++ b/tests/Core/Controller/LoginControllerTest.php @@ -83,7 +83,7 @@ class LoginControllerTest extends TestCase { /** @var IInitialStateService|MockObject */ private $initialStateService; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->request = $this->createMock(IRequest::class); $this->userManager = $this->createMock(\OC\User\Manager::class); diff --git a/tests/Core/Controller/NavigationControllerTest.php b/tests/Core/Controller/NavigationControllerTest.php index ce77d1d0684..4a4ad4b49e3 100644 --- a/tests/Core/Controller/NavigationControllerTest.php +++ b/tests/Core/Controller/NavigationControllerTest.php @@ -45,7 +45,7 @@ class NavigationControllerTest extends TestCase { /** @var NavigationController */ private $controller; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->request = $this->createMock(IRequest::class); diff --git a/tests/Core/Controller/OCSControllerTest.php b/tests/Core/Controller/OCSControllerTest.php index d1e7f2c4350..f0fbce86b8c 100644 --- a/tests/Core/Controller/OCSControllerTest.php +++ b/tests/Core/Controller/OCSControllerTest.php @@ -48,7 +48,7 @@ class OCSControllerTest extends TestCase { /** @var OCSController */ private $controller; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->request = $this->createMock(IRequest::class); diff --git a/tests/Core/Controller/PreviewControllerTest.php b/tests/Core/Controller/PreviewControllerTest.php index 145fb93f63a..65252561796 100644 --- a/tests/Core/Controller/PreviewControllerTest.php +++ b/tests/Core/Controller/PreviewControllerTest.php @@ -49,7 +49,7 @@ class PreviewControllerTest extends \Test\TestCase { /** @var PreviewController|\PHPUnit_Framework_MockObject_MockObject */ private $controller; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->rootFolder = $this->createMock(IRootFolder::class); diff --git a/tests/Core/Controller/UserControllerTest.php b/tests/Core/Controller/UserControllerTest.php index 489433f10b8..b5e43b2999d 100644 --- a/tests/Core/Controller/UserControllerTest.php +++ b/tests/Core/Controller/UserControllerTest.php @@ -38,7 +38,7 @@ class UserControllerTest extends TestCase { /** @var UserController */ private $controller; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->userManager = $this->createMock(IUserManager::class); diff --git a/tests/Core/Controller/WipeControllerTest.php b/tests/Core/Controller/WipeControllerTest.php index ebbf6509009..73d16a63a6e 100644 --- a/tests/Core/Controller/WipeControllerTest.php +++ b/tests/Core/Controller/WipeControllerTest.php @@ -40,7 +40,7 @@ class WipeControllerTest extends TestCase { /** @var WipeController */ private $controller; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->remoteWipe = $this->createMock(RemoteWipe::class); diff --git a/tests/Core/Middleware/TwoFactorMiddlewareTest.php b/tests/Core/Middleware/TwoFactorMiddlewareTest.php index 65db9733ab2..2198cc7d5b4 100644 --- a/tests/Core/Middleware/TwoFactorMiddlewareTest.php +++ b/tests/Core/Middleware/TwoFactorMiddlewareTest.php @@ -162,10 +162,10 @@ class TwoFactorMiddlewareTest extends TestCase { $this->middleware->beforeController($this->controller, 'index'); } - /** - * @expectedException \OC\Authentication\Exceptions\TwoFactorAuthRequiredException - */ + public function testBeforeControllerTwoFactorAuthRequired() { + $this->expectException(\OC\Authentication\Exceptions\TwoFactorAuthRequiredException::class); + $user = $this->createMock(IUser::class); $this->reflector->expects($this->once()) @@ -190,10 +190,10 @@ class TwoFactorMiddlewareTest extends TestCase { $this->middleware->beforeController($this->controller, 'index'); } - /** - * @expectedException \OC\Authentication\Exceptions\UserAlreadyLoggedInException - */ + public function testBeforeControllerUserAlreadyLoggedIn() { + $this->expectException(\OC\Authentication\Exceptions\UserAlreadyLoggedInException::class); + $user = $this->createMock(IUser::class); $this->reflector |