diff options
Diffstat (limited to 'tests/lib/Preview/Provider.php')
-rw-r--r-- | tests/lib/Preview/Provider.php | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/tests/lib/Preview/Provider.php b/tests/lib/Preview/Provider.php index 41a2a4ca3c4..d8f10c430e4 100644 --- a/tests/lib/Preview/Provider.php +++ b/tests/lib/Preview/Provider.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -7,35 +8,34 @@ namespace Test\Preview; +use OC\Files\Filesystem; use OC\Files\Node\File; +use OC\Files\Storage\Storage; +use OC\Files\Storage\Temporary; +use OC\Files\View; +use OC\Preview\TXT; use OCP\Files\IRootFolder; +use OCP\IImage; +use OCP\IUserManager; +use OCP\Server; abstract class Provider extends \Test\TestCase { - /** @var string */ - protected $imgPath; - /** @var int */ - protected $width; - /** @var int */ - protected $height; - /** @var \OC\Preview\Provider */ + protected string $imgPath; + protected int $width; + protected int $height; + /** @var \OC\Preview\Provider|mixed $provider */ protected $provider; - /** @var int */ - protected $maxWidth = 1024; - /** @var int */ - protected $maxHeight = 1024; - /** @var bool */ - protected $scalingUp = false; - /** @var int */ - protected $userId; - /** @var \OC\Files\View */ - protected $rootView; - /** @var \OC\Files\Storage\Storage */ - protected $storage; + protected int $maxWidth = 1024; + protected int $maxHeight = 1024; + protected bool $scalingUp = false; + protected string $userId; + protected View $rootView; + protected Storage $storage; protected function setUp(): void { parent::setUp(); - $userManager = \OC::$server->getUserManager(); + $userManager = Server::get(IUserManager::class); $userManager->clearBackends(); $backend = new \Test\Util\User\Dummy(); $userManager->registerBackend($backend); @@ -44,10 +44,10 @@ abstract class Provider extends \Test\TestCase { $backend->createUser($userId, $userId); $this->loginAsUser($userId); - $this->storage = new \OC\Files\Storage\Temporary([]); - \OC\Files\Filesystem::mount($this->storage, [], '/' . $userId . '/'); + $this->storage = new Temporary([]); + Filesystem::mount($this->storage, [], '/' . $userId . '/'); - $this->rootView = new \OC\Files\View(''); + $this->rootView = new View(''); $this->rootView->mkdir('/' . $userId); $this->rootView->mkdir('/' . $userId . '/files'); @@ -72,12 +72,12 @@ abstract class Provider extends \Test\TestCase { /** * Launches all the tests we have * - * @dataProvider dimensionsDataProvider * @requires extension imagick * * @param int $widthAdjustment * @param int $heightAdjustment */ + #[\PHPUnit\Framework\Attributes\DataProvider('dimensionsDataProvider')] public function testGetThumbnail($widthAdjustment, $heightAdjustment): void { $ratio = round($this->width / $this->height, 2); $this->maxWidth = $this->width - $widthAdjustment; @@ -91,7 +91,7 @@ abstract class Provider extends \Test\TestCase { $preview = $this->getPreview($this->provider); // The TXT provider uses the max dimensions to create its canvas, // so the ratio will always be the one of the max dimension canvas - if (!$this->provider instanceof \OC\Preview\TXT) { + if (!$this->provider instanceof TXT) { $this->doesRatioMatch($preview, $ratio); } $this->doesPreviewFit($preview); @@ -121,10 +121,10 @@ abstract class Provider extends \Test\TestCase { * * @param \OC\Preview\Provider $provider * - * @return bool|\OCP\IImage + * @return bool|IImage */ private function getPreview($provider) { - $file = new File(\OC::$server->get(IRootFolder::class), $this->rootView, $this->imgPath); + $file = new File(Server::get(IRootFolder::class), $this->rootView, $this->imgPath); $preview = $provider->getThumbnail($file, $this->maxWidth, $this->maxHeight, $this->scalingUp); if (get_class($this) === BitmapTest::class && $preview === null) { @@ -140,7 +140,7 @@ abstract class Provider extends \Test\TestCase { /** * Checks if the preview ratio matches the original ratio * - * @param \OCP\IImage $preview + * @param IImage $preview * @param int $ratio */ private function doesRatioMatch($preview, $ratio) { @@ -151,7 +151,7 @@ abstract class Provider extends \Test\TestCase { /** * Tests if a max size preview of smaller dimensions can be created * - * @param \OCP\IImage $preview + * @param IImage $preview */ private function doesPreviewFit($preview) { $maxDimRatio = round($this->maxWidth / $this->maxHeight, 2); |