aboutsummaryrefslogtreecommitdiffstats
path: root/tests/Core/Command/Encryption/EnableTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Core/Command/Encryption/EnableTest.php')
-rw-r--r--tests/Core/Command/Encryption/EnableTest.php47
1 files changed, 21 insertions, 26 deletions
diff --git a/tests/Core/Command/Encryption/EnableTest.php b/tests/Core/Command/Encryption/EnableTest.php
index 2d463452add..32d1a7576f5 100644
--- a/tests/Core/Command/Encryption/EnableTest.php
+++ b/tests/Core/Command/Encryption/EnableTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -45,7 +46,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'],
@@ -55,17 +56,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 {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataEnable')]
+ 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 +71,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]);
}