]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix tests on PHP 8.1 for encryption, files_sharing, files_version,
authorCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 26 Oct 2021 14:42:19 +0000 (16:42 +0200)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 16 Dec 2021 08:43:29 +0000 (09:43 +0100)
  files_trashbin and theming apps

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/encryption/lib/Command/FixEncryptedVersion.php
apps/encryption/tests/Crypto/EncryptAllTest.php
apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php
apps/files_trashbin/tests/Controller/PreviewControllerTest.php
apps/files_versions/tests/Controller/PreviewControllerTest.php
apps/theming/tests/Controller/IconControllerTest.php
apps/theming/tests/Controller/ThemingControllerTest.php

index d51f64c8ef9141d1bd1362460040f9c5b8353283..073c1f1438a886593c122ccdadc44e42b3dfeca4 100644 (file)
@@ -116,10 +116,7 @@ class FixEncryptedVersion extends Command {
                $user = (string)$input->getArgument('user');
                $pathToWalk = "/$user/files";
 
-               /**
-                * trim() returns an empty string when the argument is an unset/null
-                */
-               $pathOption = \trim($input->getOption('path'), '/');
+               $pathOption = \trim(($input->getOption('path') ?? ''), '/');
                if ($pathOption !== "") {
                        $pathToWalk = "$pathToWalk/$pathOption";
                }
index 4a00b67f0b1fcd01662f7ffac13d0120721a83b4..e5c10dd67e8bfc359e5e5fda3c7c1da5beca2b30 100644 (file)
@@ -117,9 +117,12 @@ class EncryptAllTest extends TestCase {
                $this->userInterface = $this->getMockBuilder(UserInterface::class)
                        ->disableOriginalConstructor()->getMock();
 
+               /* We need format method to return a string */
+               $outputFormatter = $this->createMock(OutputFormatterInterface::class);
+               $outputFormatter->method('format')->willReturnArgument(0);
 
                $this->outputInterface->expects($this->any())->method('getFormatter')
-                       ->willReturn($this->createMock(OutputFormatterInterface::class));
+                       ->willReturn($outputFormatter);
 
                $this->userManager->expects($this->any())->method('getBackends')->willReturn([$this->userInterface]);
                $this->userInterface->expects($this->any())->method('getUsers')->willReturn(['user1', 'user2']);
index e089cd9e34b2f72cfc98c56108a79c8b157c1f1d..9f852721678c8056b3f02dba326c8b263554712c 100644 (file)
@@ -137,6 +137,8 @@ class PublicPreviewControllerTest extends TestCase {
                        ->willReturn($file);
 
                $preview = $this->createMock(ISimpleFile::class);
+               $preview->method('getName')->willReturn('name');
+               $preview->method('getMTime')->willReturn(42);
                $this->previewManager->method('getPreview')
                        ->with($this->equalTo($file), 10, 10, false)
                        ->willReturn($preview);
@@ -192,6 +194,8 @@ class PublicPreviewControllerTest extends TestCase {
                        ->willReturn($file);
 
                $preview = $this->createMock(ISimpleFile::class);
+               $preview->method('getName')->willReturn('name');
+               $preview->method('getMTime')->willReturn(42);
                $this->previewManager->method('getPreview')
                        ->with($this->equalTo($file), 10, 10, false)
                        ->willReturn($preview);
index 1a36473ecf1fc188eac4ba17aff3feb67cc0a3db..441222bea1979d9dc9b642fa7eacf9750a10b4ea 100644 (file)
@@ -144,6 +144,8 @@ class PreviewControllerTest extends TestCase {
                        ->willReturn($file);
 
                $preview = $this->createMock(ISimpleFile::class);
+               $preview->method('getName')->willReturn('name');
+               $preview->method('getMTime')->willReturn(42);
                $this->previewManager->method('getPreview')
                        ->with($this->equalTo($file), 10, 10, true, IPreview::MODE_FILL, 'myMime')
                        ->willReturn($preview);
index 64a060e3108093d1e75504cfbc8ba68ad3091f5a..0457d0d5f249103cec3c8395a19a91372f5651c6 100644 (file)
@@ -141,6 +141,8 @@ class PreviewControllerTest extends TestCase {
                        ->willReturn($file);
 
                $preview = $this->createMock(ISimpleFile::class);
+               $preview->method('getName')->willReturn('name');
+               $preview->method('getMTime')->willReturn(42);
                $this->previewManager->method('getPreview')
                        ->with($this->equalTo($file), 10, 10, true, IPreview::MODE_FILL, 'myMime')
                        ->willReturn($preview);
index 821291427d9ad35c92fbbf7d5df01f678fbfda3a..049547821683ff1fa1e591cf5d528458701cd273 100644 (file)
@@ -91,6 +91,8 @@ class IconControllerTest extends TestCase {
                $icon->expects($this->any())->method('getContent')->willReturn($data);
                $icon->expects($this->any())->method('getMimeType')->willReturn('image type');
                $icon->expects($this->any())->method('getEtag')->willReturn('my etag');
+               $icon->expects($this->any())->method('getName')->willReturn('my name');
+               $icon->expects($this->any())->method('getMTime')->willReturn(42);
                $icon->method('getName')->willReturn($filename);
                return new SimpleFile($icon);
        }
index b85b2bb6ad0057e275993a94848c53b7e83249fc..cff2028809dc9516e8f3beb2f52ffdc8579649ac 100644 (file)
@@ -748,6 +748,7 @@ class ThemingControllerTest extends TestCase {
                $this->appManager->expects($this->once())->method('getAppPath')->with('theming')->willReturn(\OC::$SERVERROOT . '/theming');
                $file = $this->createMock(ISimpleFile::class);
                $file->expects($this->any())->method('getName')->willReturn('theming.css');
+               $file->expects($this->any())->method('getMTime')->willReturn(42);
                $file->expects($this->any())->method('getContent')->willReturn('compiled');
                $this->scssCacher->expects($this->once())->method('process')->willReturn(true);
                $this->scssCacher->expects($this->once())->method('getCachedCSS')->willReturn($file);
@@ -763,6 +764,7 @@ class ThemingControllerTest extends TestCase {
                $this->appManager->expects($this->once())->method('getAppPath')->with('theming')->willReturn(\OC::$SERVERROOT . '/theming');
                $file = $this->createMock(ISimpleFile::class);
                $file->expects($this->any())->method('getName')->willReturn('theming.css');
+               $file->expects($this->any())->method('getMTime')->willReturn(42);
                $file->expects($this->any())->method('getContent')->willReturn('compiled');
                $this->scssCacher->expects($this->once())->method('process')->willReturn(true);
                $this->scssCacher->expects($this->once())->method('getCachedCSS')->willThrowException(new NotFoundException());
@@ -776,6 +778,7 @@ class ThemingControllerTest extends TestCase {
                $this->appManager->expects($this->once())->method('getAppPath')->with('theming')->willReturn('/outside/serverroot/theming');
                $file = $this->createMock(ISimpleFile::class);
                $file->expects($this->any())->method('getName')->willReturn('theming.css');
+               $file->expects($this->any())->method('getMTime')->willReturn(42);
                $file->expects($this->any())->method('getContent')->willReturn('compiled');
                $this->scssCacher->expects($this->once())->method('process')->with('/outside/serverroot/theming', 'css/theming.scss', 'theming')->willReturn(true);
                $this->scssCacher->expects($this->once())->method('getCachedCSS')->willReturn($file);