diff options
Diffstat (limited to 'tests/Core/Command/Encryption')
5 files changed, 50 insertions, 51 deletions
diff --git a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php index ecb3faaa25d..1b34d16a5db 100644 --- a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php +++ b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php @@ -159,9 +159,9 @@ class ChangeKeyStorageRootTest extends TestCase { ] )->setMethods(['prepareNewRoot', 'moveSystemKeys', 'moveUserKeys'])->getMock(); - $changeKeyStorageRoot->expects($this->at(0))->method('prepareNewRoot')->with('newRoot'); - $changeKeyStorageRoot->expects($this->at(1))->method('moveSystemKeys')->with('oldRoot', 'newRoot'); - $changeKeyStorageRoot->expects($this->at(2))->method('moveUserKeys')->with('oldRoot', 'newRoot', $this->outputInterface); + $changeKeyStorageRoot->expects($this->once())->method('prepareNewRoot')->with('newRoot'); + $changeKeyStorageRoot->expects($this->once())->method('moveSystemKeys')->with('oldRoot', 'newRoot'); + $changeKeyStorageRoot->expects($this->once())->method('moveUserKeys')->with('oldRoot', 'newRoot', $this->outputInterface); $this->invokePrivate($changeKeyStorageRoot, 'moveAllKeys', ['oldRoot', 'newRoot', $this->outputInterface]); } diff --git a/tests/Core/Command/Encryption/DecryptAllTest.php b/tests/Core/Command/Encryption/DecryptAllTest.php index c78500fd9d8..c60e5aff99c 100644 --- a/tests/Core/Command/Encryption/DecryptAllTest.php +++ b/tests/Core/Command/Encryption/DecryptAllTest.php @@ -86,17 +86,16 @@ class DecryptAllTest extends TestCase { public function testMaintenanceAndTrashbin() { // on construct we enable single-user-mode and disable the trash bin - $this->config->expects($this->at(1)) + // on destruct we disable single-user-mode again and enable the trash bin + $this->config->expects($this->exactly(2)) ->method('setSystemValue') - ->with('maintenance', true); + ->withConsecutive( + ['maintenance', true], + ['maintenance', false], + ); $this->appManager->expects($this->once()) ->method('disableApp') ->with('files_trashbin'); - - // on destruct wi disable single-user-mode again and enable the trash bin - $this->config->expects($this->at(2)) - ->method('setSystemValue') - ->with('maintenance', false); $this->appManager->expects($this->once()) ->method('enableApp') ->with('files_trashbin'); @@ -142,9 +141,12 @@ class DecryptAllTest extends TestCase { ->willReturn('user1'); if ($encryptionEnabled) { - $this->config->expects($this->at(1)) + $this->config->expects($this->exactly(2)) ->method('setAppValue') - ->with('core', 'encryption_enabled', 'no'); + ->withConsecutive( + ['core', 'encryption_enabled', 'no'], + ['core', 'encryption_enabled', 'yes'], + ); $this->questionHelper->expects($this->once()) ->method('ask') ->willReturn($continue); @@ -154,9 +156,6 @@ class DecryptAllTest extends TestCase { ->with($this->consoleInput, $this->consoleOutput, 'user1'); } else { $this->decryptAll->expects($this->never())->method('decryptAll'); - $this->config->expects($this->at(2)) - ->method('setAppValue') - ->with('core', 'encryption_enabled', 'yes'); } } else { $this->config->expects($this->never())->method('setAppValue'); @@ -188,14 +187,13 @@ class DecryptAllTest extends TestCase { $this->questionHelper ); - $this->config->expects($this->at(1)) - ->method('setAppValue') - ->with('core', 'encryption_enabled', 'no'); - // make sure that we enable encryption again after a exception was thrown - $this->config->expects($this->at(4)) + $this->config->expects($this->exactly(2)) ->method('setAppValue') - ->with('core', 'encryption_enabled', 'yes'); + ->withConsecutive( + ['core', 'encryption_enabled', 'no'], + ['core', 'encryption_enabled', 'yes'], + ); $this->encryptionManager->expects($this->once()) ->method('isEnabled') diff --git a/tests/Core/Command/Encryption/EnableTest.php b/tests/Core/Command/Encryption/EnableTest.php index c1656054ecd..9c7127085ca 100644 --- a/tests/Core/Command/Encryption/EnableTest.php +++ b/tests/Core/Command/Encryption/EnableTest.php @@ -80,42 +80,40 @@ class EnableTest extends TestCase { * @param string $expectedDefaultModuleString */ public function testEnable($oldStatus, $defaultModule, $availableModules, $isUpdating, $expectedString, $expectedDefaultModuleString) { - $invokeCount = 0; - $this->config->expects($this->at($invokeCount)) - ->method('getAppValue') - ->with('core', 'encryption_enabled', $this->anything()) - ->willReturn($oldStatus); - $invokeCount++; - if ($isUpdating) { $this->config->expects($this->once()) ->method('setAppValue') ->with('core', 'encryption_enabled', 'yes'); - $invokeCount++; } $this->manager->expects($this->atLeastOnce()) ->method('getEncryptionModules') ->willReturn($availableModules); - if (!empty($availableModules)) { - $this->config->expects($this->at($invokeCount)) + if (empty($availableModules)) { + $this->config->expects($this->once()) ->method('getAppValue') - ->with('core', 'default_encryption_module', $this->anything()) - ->willReturn($defaultModule); + ->with('core', 'encryption_enabled', $this->anything()) + ->willReturn($oldStatus); + } else { + $this->config->expects($this->exactly(2)) + ->method('getAppValue') + ->withConsecutive( + ['core', 'encryption_enabled', $this->anything()], + ['core', 'default_encryption_module', $this->anything()], + )->willReturnOnConsecutiveCalls( + $oldStatus, + $defaultModule, + ); } - $this->consoleOutput->expects($this->at(0)) - ->method('writeln') - ->with($this->stringContains($expectedString)); - - $this->consoleOutput->expects($this->at(1)) - ->method('writeln') - ->with(''); - - $this->consoleOutput->expects($this->at(2)) + $this->consoleOutput->expects($this->exactly(3)) ->method('writeln') - ->with($this->stringContains($expectedDefaultModuleString)); + ->withConsecutive( + [$this->stringContains($expectedString)], + [''], + [$this->stringContains($expectedDefaultModuleString)], + ); self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); } diff --git a/tests/Core/Command/Encryption/EncryptAllTest.php b/tests/Core/Command/Encryption/EncryptAllTest.php index 1190a98843f..4ba9e32fa16 100644 --- a/tests/Core/Command/Encryption/EncryptAllTest.php +++ b/tests/Core/Command/Encryption/EncryptAllTest.php @@ -88,8 +88,12 @@ class EncryptAllTest extends TestCase { // enable single user mode to avoid that other user login during encryption // destructor should disable the single user mode again $this->config->expects($this->once())->method('getSystemValueBool')->with('maintenance', false)->willReturn(false); - $this->config->expects($this->at(1))->method('setSystemValue')->with('maintenance', true); - $this->config->expects($this->at(2))->method('setSystemValue')->with('maintenance', false); + $this->config->expects($this->exactly(2)) + ->method('setSystemValue') + ->withConsecutive( + ['maintenance', true], + ['maintenance', false], + ); $instance = new EncryptAll($this->encryptionManager, $this->appManager, $this->config, $this->questionHelper); $this->invokePrivate($instance, 'forceMaintenanceAndTrashbin'); diff --git a/tests/Core/Command/Encryption/SetDefaultModuleTest.php b/tests/Core/Command/Encryption/SetDefaultModuleTest.php index 015964e1357..4a39fc0aefb 100644 --- a/tests/Core/Command/Encryption/SetDefaultModuleTest.php +++ b/tests/Core/Command/Encryption/SetDefaultModuleTest.php @@ -127,13 +127,12 @@ class SetDefaultModuleTest extends TestCase { ->with('maintenance', false) ->willReturn(true); - $this->consoleOutput->expects($this->at(0)) + $this->consoleOutput->expects($this->exactly(2)) ->method('writeln') - ->with($this->stringContains('Maintenance mode must be disabled when setting default module,')); - - $this->consoleOutput->expects($this->at(1)) - ->method('writeln') - ->with($this->stringContains('in order to load the relevant encryption modules correctly.')); + ->withConsecutive( + [$this->stringContains('Maintenance mode must be disabled when setting default module,')], + [$this->stringContains('in order to load the relevant encryption modules correctly.')], + ); self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); } |