Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/lib/Preview/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
namespace Test\Preview;

use OC\Files\Node\File;
use OC\Preview\Provider as PreviewProvider;
use OCP\Files\IRootFolder;
use OCP\Preview\IProviderV2;

abstract class Provider extends \Test\TestCase {
/** @var string */
Expand All @@ -18,7 +20,7 @@ abstract class Provider extends \Test\TestCase {
protected $width;
/** @var int */
protected $height;
/** @var \OC\Preview\Provider */
/** @var IProviderV2|PreviewProvider */
protected $provider;
/** @var int */
protected $maxWidth = 1024;
Expand Down Expand Up @@ -126,7 +128,9 @@ protected function prepareTestFile($fileName, $fileContent) {
*/
private function getPreview($provider) {
$file = new File(\OC::$server->get(IRootFolder::class), $this->rootView, $this->imgPath);
$preview = $provider->getThumbnail($file, $this->maxWidth, $this->maxHeight, $this->scalingUp);
$preview = ($provider instanceof PreviewProvider)
? $provider->getThumbnail($file, $this->maxWidth, $this->maxHeight, $this->scalingUp, $this->rootView)
: $provider->getThumbnail($file, $this->maxWidth, $this->maxHeight, $this->scalingUp);

if (get_class($this) === BitmapTest::class && $preview === null) {
$this->markTestSkipped('An error occured while operating with Imagick.');
Expand Down
16 changes: 11 additions & 5 deletions tests/lib/Preview/SVGTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace Test\Preview;

use OCP\Files\File;

/**
* Class SVGTest
*
Expand Down Expand Up @@ -53,15 +55,17 @@ public function testGetThumbnailSVGHref(string $content): void {
</svg>');
rewind($handle);

$file = $this->createMock(\OCP\Files\File::class);
$file = $this->createMock(File::class);
$file->method('fopen')
->willReturn($handle);

self::assertNull($this->provider->getThumbnail($file, 512, 512));
}

#[\PHPUnit\Framework\Attributes\DataProvider('dataGetThumbnailSVGHrefNamespace')]
#[\PHPUnit\Framework\Attributes\RequiresPhpExtension('imagick')]
/**
* @dataProvider dataGetThumbnailSVGHrefNamespace
* @requires extension imagick
*/
public function testGetThumbnailSvgHrefNamespace(string $namespace): void {
$handle = fopen('php://temp', 'w+');
fwrite($handle, '<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:' . $namespace . '="http://www.w3.org/1999/xlink">
Expand All @@ -87,8 +91,10 @@ public static function dataGetThumbnailSVGHrefNamespace(): array {
];
}

#[\PHPUnit\Framework\Attributes\DataProvider('dataGetThumbnailSvgEncoded')]
#[\PHPUnit\Framework\Attributes\RequiresPhpExtension('imagick')]
/**
* @dataProvider dataGetThumbnailSvgEncoded
* @requires extension imagick
*/
public function testGetThumbnailSvgEncoded(string $content): void {
$handle = fopen('php://temp', 'w+');
fwrite($handle, $content);
Expand Down
Loading