Fix tests on PHP 8.1 for encryption, files_sharing, files_version,

files_trashbin and theming apps

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2021-10-26 16:42:19 +02:00
parent 6b770eb579
commit 37f8f7a5a1
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
7 changed files with 18 additions and 5 deletions

View 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";
}

View 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']);

View 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);

View 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);

View 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);

View 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);
}

View 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);