diff options
author | Joas Schilling <coding@schilljs.com> | 2025-05-02 14:00:10 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2025-05-02 16:47:42 +0200 |
commit | c24f5fb256f53836727d3479e0fcf79d680ca2ca (patch) | |
tree | 97e2ee14c40ed1cf2237eacd26f69375235e8419 /tests/Core/Command/Maintenance | |
parent | 9a16e4fd1407f0490136f6cfeec184be4b219dce (diff) | |
download | nextcloud-server-test/noid/more-phpunit-10.tar.gz nextcloud-server-test/noid/more-phpunit-10.zip |
test: Finish migrating tests/Core/ to PHPUnit 10 compatible codetest/noid/more-phpunit-10
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/Core/Command/Maintenance')
-rw-r--r-- | tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php | 55 | ||||
-rw-r--r-- | tests/Core/Command/Maintenance/ModeTest.php | 2 |
2 files changed, 32 insertions, 25 deletions
diff --git a/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php b/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php index d8c82de19ac..2f232837fe2 100644 --- a/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php +++ b/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php @@ -33,15 +33,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 +59,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) { + $expected = array_shift($calls); + $this->assertStringContainsString($expected, $message); + }); self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); } @@ -103,14 +102,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) { + $expected = array_shift($calls); + $this->assertStringContainsString($expected, $message); + }); self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); } @@ -153,13 +156,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) { + $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..85efbffdc0b 100644 --- a/tests/Core/Command/Maintenance/ModeTest.php +++ b/tests/Core/Command/Maintenance/ModeTest.php @@ -67,7 +67,7 @@ class ModeTest extends TestCase { * * @return array */ - public function getExecuteTestData(): array { + public static function getExecuteTestData(): array { return [ 'off -> on' => [ 'on', // command option |