diff options
Diffstat (limited to 'tests/Core/Command/Maintenance')
4 files changed, 38 insertions, 27 deletions
diff --git a/tests/Core/Command/Maintenance/DataFingerprintTest.php b/tests/Core/Command/Maintenance/DataFingerprintTest.php index 3d56d891bef..99004a7a5f5 100644 --- a/tests/Core/Command/Maintenance/DataFingerprintTest.php +++ b/tests/Core/Command/Maintenance/DataFingerprintTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -35,7 +36,7 @@ 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); } diff --git a/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php b/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php index d8c82de19ac..b85dcf87bbc 100644 --- a/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php +++ b/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -33,15 +34,10 @@ 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); } @@ -64,12 +60,16 @@ class UpdateDBTest extends TestCase { $this->loader->expects($this->never()) ->method('updateFilecache'); + $calls = [ + 'Added 0 new mimetypes', + 'Updated 0 filecache rows', + ]; $this->consoleOutput->expects($this->exactly(2)) ->method('writeln') - ->withConsecutive( - ['Added 0 new mimetypes'], - ['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]); } @@ -103,14 +103,18 @@ class UpdateDBTest extends TestCase { ->with('new', 2) ->willReturn(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') - ->withConsecutive( - ['Added mimetype "testing/newmimetype" to database'], - ['Updated 3 filecache rows for mimetype "testing/newmimetype"'], - ['Added 1 new mimetypes'], - ['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]); } @@ -153,13 +157,17 @@ class UpdateDBTest extends TestCase { ->with('ext', 1) ->willReturn(3); + $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') - ->withConsecutive( - ['Updated 3 filecache rows for mimetype "testing/existingmimetype"'], - ['Added 0 new mimetypes'], - ['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 a4c33474745..5a9a90b0197 100644 --- a/tests/Core/Command/Maintenance/ModeTest.php +++ b/tests/Core/Command/Maintenance/ModeTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -67,7 +68,7 @@ class ModeTest extends TestCase { * * @return array */ - public function getExecuteTestData(): array { + public static function getExecuteTestData(): array { return [ 'off -> on' => [ 'on', // command option @@ -111,7 +112,6 @@ 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 @@ -119,6 +119,7 @@ class ModeTest extends TestCase { * @param string $expectedOutput The expected command output. * @throws \Exception */ + #[\PHPUnit\Framework\Attributes\DataProvider('getExecuteTestData')] public function testExecute( string $option, bool $currentMaintenanceState, diff --git a/tests/Core/Command/Maintenance/UpdateTheme.php b/tests/Core/Command/Maintenance/UpdateTheme.php index 41b95d358d3..9c9a2b903a7 100644 --- a/tests/Core/Command/Maintenance/UpdateTheme.php +++ b/tests/Core/Command/Maintenance/UpdateTheme.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later |