aboutsummaryrefslogtreecommitdiffstats
path: root/tests/Core/Command/Maintenance
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Core/Command/Maintenance')
-rw-r--r--tests/Core/Command/Maintenance/DataFingerprintTest.php25
-rw-r--r--tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php98
-rw-r--r--tests/Core/Command/Maintenance/ModeTest.php14
-rw-r--r--tests/Core/Command/Maintenance/UpdateTheme.php24
4 files changed, 61 insertions, 100 deletions
diff --git a/tests/Core/Command/Maintenance/DataFingerprintTest.php b/tests/Core/Command/Maintenance/DataFingerprintTest.php
index 185a8d1576a..99004a7a5f5 100644
--- a/tests/Core/Command/Maintenance/DataFingerprintTest.php
+++ b/tests/Core/Command/Maintenance/DataFingerprintTest.php
@@ -1,22 +1,9 @@
<?php
+
/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, 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\Maintenance;
@@ -49,11 +36,11 @@ class DataFingerprintTest extends TestCase {
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
- /** @var \OCP\IConfig $config */
+ /** @var IConfig $config */
$this->command = new DataFingerprint($this->config, $this->timeFactory);
}
- public function testSetFingerPrint() {
+ public function testSetFingerPrint(): void {
$this->timeFactory->expects($this->once())
->method('getTime')
->willReturn(42);
diff --git a/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php b/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php
index bd08a5348a2..b85dcf87bbc 100644
--- a/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php
+++ b/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php
@@ -1,22 +1,9 @@
<?php
+
/**
- * @author Robin McCorkell <rmccorkell@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\Maintenance\Mimetype;
@@ -47,20 +34,15 @@ class UpdateDBTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->detector = $this->getMockBuilder(Detection::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->loader = $this->getMockBuilder(Loader::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
- $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
+ $this->detector = $this->createMock(Detection::class);
+ $this->loader = $this->createMock(Loader::class);
+ $this->consoleInput = $this->createMock(InputInterface::class);
+ $this->consoleOutput = $this->createMock(OutputInterface::class);
$this->command = new UpdateDB($this->detector, $this->loader);
}
- public function testNoop() {
+ public function testNoop(): void {
$this->consoleInput->method('getOption')
->with('repair-filecache')
->willReturn(false);
@@ -78,17 +60,21 @@ class UpdateDBTest extends TestCase {
$this->loader->expects($this->never())
->method('updateFilecache');
- $this->consoleOutput->expects($this->at(0))
- ->method('writeln')
- ->with('Added 0 new mimetypes');
- $this->consoleOutput->expects($this->at(1))
+ $calls = [
+ 'Added 0 new mimetypes',
+ 'Updated 0 filecache rows',
+ ];
+ $this->consoleOutput->expects($this->exactly(2))
->method('writeln')
- ->with('Updated 0 filecache rows');
+ ->willReturnCallback(function ($message) use (&$calls): void {
+ $expected = array_shift($calls);
+ $this->assertStringContainsString($expected, $message);
+ });
self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}
- public function testAddMimetype() {
+ public function testAddMimetype(): void {
$this->consoleInput->method('getOption')
->with('repair-filecache')
->willReturn(false);
@@ -117,24 +103,23 @@ class UpdateDBTest extends TestCase {
->with('new', 2)
->willReturn(3);
- $this->consoleOutput->expects($this->at(0))
- ->method('writeln')
- ->with('Added mimetype "testing/newmimetype" to database');
- $this->consoleOutput->expects($this->at(1))
- ->method('writeln')
- ->with('Updated 3 filecache rows for mimetype "testing/newmimetype"');
-
- $this->consoleOutput->expects($this->at(2))
- ->method('writeln')
- ->with('Added 1 new mimetypes');
- $this->consoleOutput->expects($this->at(3))
+ $calls = [
+ 'Added mimetype "testing/newmimetype" to database',
+ 'Updated 3 filecache rows for mimetype "testing/newmimetype"',
+ 'Added 1 new mimetypes',
+ 'Updated 3 filecache rows',
+ ];
+ $this->consoleOutput->expects($this->exactly(4))
->method('writeln')
- ->with('Updated 3 filecache rows');
+ ->willReturnCallback(function ($message) use (&$calls): void {
+ $expected = array_shift($calls);
+ $this->assertStringContainsString($expected, $message);
+ });
self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}
- public function testSkipComments() {
+ public function testSkipComments(): void {
$this->detector->expects($this->once())
->method('getAllMappings')
->willReturn([
@@ -146,7 +131,7 @@ class UpdateDBTest extends TestCase {
self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}
- public function testRepairFilecache() {
+ public function testRepairFilecache(): void {
$this->consoleInput->method('getOption')
->with('repair-filecache')
->willReturn(true);
@@ -172,16 +157,17 @@ class UpdateDBTest extends TestCase {
->with('ext', 1)
->willReturn(3);
- $this->consoleOutput->expects($this->at(0))
- ->method('writeln')
- ->with('Updated 3 filecache rows for mimetype "testing/existingmimetype"');
-
- $this->consoleOutput->expects($this->at(1))
- ->method('writeln')
- ->with('Added 0 new mimetypes');
- $this->consoleOutput->expects($this->at(2))
+ $calls = [
+ 'Updated 3 filecache rows for mimetype "testing/existingmimetype"',
+ 'Added 0 new mimetypes',
+ 'Updated 3 filecache rows',
+ ];
+ $this->consoleOutput->expects($this->exactly(3))
->method('writeln')
- ->with('Updated 3 filecache rows');
+ ->willReturnCallback(function ($message) use (&$calls): void {
+ $expected = array_shift($calls);
+ $this->assertStringContainsString($expected, $message);
+ });
self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}
diff --git a/tests/Core/Command/Maintenance/ModeTest.php b/tests/Core/Command/Maintenance/ModeTest.php
index 1e8af354d50..5a9a90b0197 100644
--- a/tests/Core/Command/Maintenance/ModeTest.php
+++ b/tests/Core/Command/Maintenance/ModeTest.php
@@ -1,5 +1,9 @@
<?php
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
namespace Tests\Core\Command\Maintenance;
use OC\Core\Command\Maintenance\Mode;
@@ -64,7 +68,7 @@ class ModeTest extends TestCase {
*
* @return array
*/
- public function getExecuteTestData(): array {
+ public static function getExecuteTestData(): array {
return [
'off -> on' => [
'on', // command option
@@ -108,20 +112,20 @@ class ModeTest extends TestCase {
/**
* Asserts that execute works as expected.
*
- * @dataProvider getExecuteTestData
* @param string $option The command option.
* @param bool $currentMaintenanceState The current maintenance state.
* @param null|bool $expectedMaintenanceState
- * The expected maintenance state. Null for no change.
+ * The expected maintenance state. Null for no change.
* @param string $expectedOutput The expected command output.
* @throws \Exception
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('getExecuteTestData')]
public function testExecute(
string $option,
bool $currentMaintenanceState,
$expectedMaintenanceState,
- string $expectedOutput
- ) {
+ string $expectedOutput,
+ ): void {
$this->config->expects($this->any())
->method('getSystemValueBool')
->willReturn($currentMaintenanceState);
diff --git a/tests/Core/Command/Maintenance/UpdateTheme.php b/tests/Core/Command/Maintenance/UpdateTheme.php
index bf460b44d4e..9c9a2b903a7 100644
--- a/tests/Core/Command/Maintenance/UpdateTheme.php
+++ b/tests/Core/Command/Maintenance/UpdateTheme.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Julius Härtl <jus@bitgrid.net>
- *
- * @author Julius Härtl <jus@bitgrid.net>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Command\Maintenance;
@@ -59,7 +43,7 @@ class UpdateThemeTest extends TestCase {
$this->command = new UpdateTheme($this->detector, $this->cacheFactory);
}
- public function testThemeUpdate() {
+ public function testThemeUpdate(): void {
$this->consoleInput->method('getOption')
->with('maintenance:theme:update')
->willReturn(true);