diff options
Diffstat (limited to 'tests/Core/Command')
-rw-r--r-- | tests/Core/Command/Apps/AppsDisableTest.php | 2 | ||||
-rw-r--r-- | tests/Core/Command/Apps/AppsEnableTest.php | 2 | ||||
-rw-r--r-- | tests/Core/Command/Config/System/SetConfigTest.php | 6 | ||||
-rw-r--r-- | tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php | 11 | ||||
-rw-r--r-- | tests/Core/Command/Encryption/DecryptAllTest.php | 8 | ||||
-rw-r--r-- | tests/Core/Command/Encryption/EncryptAllTest.php | 6 | ||||
-rw-r--r-- | tests/Core/Command/Group/AddTest.php | 2 | ||||
-rw-r--r-- | tests/Core/Command/Group/AddUserTest.php | 2 | ||||
-rw-r--r-- | tests/Core/Command/Group/DeleteTest.php | 2 | ||||
-rw-r--r-- | tests/Core/Command/Group/ListCommandTest.php | 2 | ||||
-rw-r--r-- | tests/Core/Command/Group/RemoveUserTest.php | 2 | ||||
-rw-r--r-- | tests/Core/Command/Log/ManageTest.php | 24 | ||||
-rw-r--r-- | tests/Core/Command/TwoFactorAuth/DisableTest.php | 2 | ||||
-rw-r--r-- | tests/Core/Command/TwoFactorAuth/EnableTest.php | 2 |
14 files changed, 38 insertions, 35 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); |