aboutsummaryrefslogtreecommitdiffstats
path: root/tests/Core/Command/Encryption/SetDefaultModuleTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Core/Command/Encryption/SetDefaultModuleTest.php')
-rw-r--r--tests/Core/Command/Encryption/SetDefaultModuleTest.php46
1 files changed, 18 insertions, 28 deletions
diff --git a/tests/Core/Command/Encryption/SetDefaultModuleTest.php b/tests/Core/Command/Encryption/SetDefaultModuleTest.php
index 015964e1357..df38d730db3 100644
--- a/tests/Core/Command/Encryption/SetDefaultModuleTest.php
+++ b/tests/Core/Command/Encryption/SetDefaultModuleTest.php
@@ -1,22 +1,9 @@
<?php
+
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Encryption;
@@ -57,7 +44,7 @@ class SetDefaultModuleTest extends TestCase {
}
- public function dataSetDefaultModule() {
+ public static function dataSetDefaultModule(): array {
return [
['ID0', 'ID0', null, null, 'already'],
['ID0', 'ID1', 'ID1', true, 'info'],
@@ -66,7 +53,6 @@ class SetDefaultModuleTest extends TestCase {
}
/**
- * @dataProvider dataSetDefaultModule
*
* @param string $oldModule
* @param string $newModule
@@ -74,7 +60,8 @@ class SetDefaultModuleTest extends TestCase {
* @param bool $updateSuccess
* @param string $expectedString
*/
- public function testSetDefaultModule($oldModule, $newModule, $updateModule, $updateSuccess, $expectedString) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataSetDefaultModule')]
+ public function testSetDefaultModule($oldModule, $newModule, $updateModule, $updateSuccess, $expectedString): void {
$this->consoleInput->expects($this->once())
->method('getArgument')
->with('module')
@@ -104,7 +91,6 @@ class SetDefaultModuleTest extends TestCase {
}
/**
- * @dataProvider dataSetDefaultModule
*
* @param string $oldModule
* @param string $newModule
@@ -112,7 +98,8 @@ class SetDefaultModuleTest extends TestCase {
* @param bool $updateSuccess
* @param string $expectedString
*/
- public function testMaintenanceMode($oldModule, $newModule, $updateModule, $updateSuccess, $expectedString) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataSetDefaultModule')]
+ public function testMaintenanceMode($oldModule, $newModule, $updateModule, $updateSuccess, $expectedString): void {
$this->consoleInput->expects($this->never())
->method('getArgument')
->with('module')
@@ -127,13 +114,16 @@ class SetDefaultModuleTest extends TestCase {
->with('maintenance', false)
->willReturn(true);
- $this->consoleOutput->expects($this->at(0))
- ->method('writeln')
- ->with($this->stringContains('Maintenance mode must be disabled when setting default module,'));
-
- $this->consoleOutput->expects($this->at(1))
+ $calls = [
+ 'Maintenance mode must be disabled when setting default module,',
+ 'in order to load the relevant encryption modules correctly.',
+ ];
+ $this->consoleOutput->expects($this->exactly(2))
->method('writeln')
- ->with($this->stringContains('in order to load the relevant encryption modules correctly.'));
+ ->willReturnCallback(function ($message) use (&$calls): void {
+ $expected = array_shift($calls);
+ $this->assertStringContainsString($expected, $message);
+ });
self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}