diff options
Diffstat (limited to 'tests/Core/Command/Encryption/EnableTest.php')
-rw-r--r-- | tests/Core/Command/Encryption/EnableTest.php | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/tests/Core/Command/Encryption/EnableTest.php b/tests/Core/Command/Encryption/EnableTest.php index 2d463452add..e4f8ae9eacf 100644 --- a/tests/Core/Command/Encryption/EnableTest.php +++ b/tests/Core/Command/Encryption/EnableTest.php @@ -45,7 +45,7 @@ class EnableTest extends TestCase { } - public function dataEnable() { + public static function dataEnable(): array { return [ ['no', null, [], true, 'Encryption enabled', 'No encryption module is loaded'], ['yes', null, [], false, 'Encryption is already enabled', 'No encryption module is loaded'], @@ -57,15 +57,8 @@ class EnableTest extends TestCase { /** * @dataProvider dataEnable - * - * @param string $oldStatus - * @param string $defaultModule - * @param array $availableModules - * @param bool $isUpdating - * @param string $expectedString - * @param string $expectedDefaultModuleString */ - public function testEnable($oldStatus, $defaultModule, $availableModules, $isUpdating, $expectedString, $expectedDefaultModuleString): void { + public function testEnable(string $oldStatus, ?string $defaultModule, array $availableModules, bool $isUpdating, string $expectedString, string $expectedDefaultModuleString): void { if ($isUpdating) { $this->config->expects($this->once()) ->method('setAppValue') @@ -79,27 +72,30 @@ class EnableTest extends TestCase { if (empty($availableModules)) { $this->config->expects($this->once()) ->method('getAppValue') - ->with('core', 'encryption_enabled', $this->anything()) - ->willReturn($oldStatus); + ->willReturnMap([ + ['core', 'encryption_enabled', 'no', $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, - ); + ->willReturnMap([ + ['core', 'encryption_enabled', 'no', $oldStatus], + ['core', 'default_encryption_module', null, $defaultModule], + ]); } + $calls = [ + [$expectedString, 0], + ['', 0], + [$expectedDefaultModuleString, 0], + ]; $this->consoleOutput->expects($this->exactly(3)) ->method('writeln') - ->withConsecutive( - [$this->stringContains($expectedString)], - [''], - [$this->stringContains($expectedDefaultModuleString)], - ); + ->willReturnCallback(function (string $message, int $level) use (&$calls): void { + $call = array_shift($calls); + $this->assertStringContainsString($call[0], $message); + $this->assertSame($call[1], $level); + }); self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); } |