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
11 changes: 8 additions & 3 deletions .github/workflows/phpunit-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,17 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
# https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, redis, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, imagick, intl, json, libxml, mbstring, openssl, pcntl, posix, redis, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
ini-file: development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up dependencies
run: composer i
run: |
sudo apt-get update
sudo apt-get install -y ghostscript
composer i
- name: Set up Nextcloud
run: |
Expand All @@ -107,7 +110,7 @@ jobs:
run: ./occ app:list && echo "======= System config =======" && ./occ config:list system

- name: PHPUnit database tests
run: composer run test:db -- --log-junit junit.xml ${{ matrix.coverage && '--coverage-clover ./clover.db.xml' || '' }}
run: composer run test:db -- --log-junit junit.xml ${{ matrix.coverage && '--coverage-clover ./clover.db.xml' || '' }} tests/lib/Preview/PostscriptTest.php

- name: Upload db code coverage
if: ${{ !cancelled() && matrix.coverage }}
Expand All @@ -125,6 +128,8 @@ jobs:
- name: Print logs
if: always()
run: |
gs --version
cat /etc/ImageMagick-6/policy.xml
cat data/nextcloud.log
summary:
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Preview/Postscript.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public function getMimeType(): string {
* {@inheritDoc}
*/
protected function getAllowedMimeTypes(): string {
return '/application\/postscript/';
return '/(application\/postscript|image\/x-eps)/';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@

namespace Test\Preview;

use OC\BinaryFinder;
use OC\Preview\Postscript;

/**
* Class BitmapTest
*
*
* @package Test\Preview
*/
#[\PHPUnit\Framework\Attributes\Group('DB')]
class BitmapTest extends Provider {
#[\PHPUnit\Framework\Attributes\RequiresPhpExtension('imagick')]
class PostscriptTest extends Provider {

protected function setUp(): void {
if (\Imagick::queryFormats('EPS') === false || \Imagick::queryFormats('PS') === false) {
$this->markTestSkipped('Imagick does not support postscript.');
}
if (\OCP\Server::get(BinaryFinder::class)->findBinaryPath('gs') === false) {
// Imagick forwards postscript rendering to Ghostscript but does not report this in queryFormats
$this->markTestSkipped('Ghostscript is not installed.');
}

parent::setUp();

$fileName = 'testimage.eps';
Expand Down
13 changes: 4 additions & 9 deletions tests/lib/Preview/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@
use OC\Files\Storage\Storage;
use OC\Files\Storage\Temporary;
use OC\Files\View;
use OC\Preview\ProviderV2;
use OC\Preview\TXT;
use OCP\Files\IRootFolder;
use OCP\IImage;
use OCP\IUserManager;
use OCP\Preview\IProviderV2;
use OCP\Server;

abstract class Provider extends \Test\TestCase {
protected string $imgPath;
protected int $width;
protected int $height;
/** @var \OC\Preview\Provider|mixed $provider */
protected $provider;
protected IProviderV2 $provider;
protected int $maxWidth = 1024;
protected int $maxHeight = 1024;
protected bool $scalingUp = false;
Expand Down Expand Up @@ -119,18 +120,12 @@ protected function prepareTestFile($fileName, $fileContent) {
/**
* Retrieves a max size thumbnail can be created
*
* @param \OC\Preview\Provider $provider
*
* @return bool|IImage
*/
private function getPreview($provider) {
private function getPreview(ProviderV2 $provider) {
$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) {
$this->markTestSkipped('An error occured while operating with Imagick.');
}

$this->assertNotEquals(false, $preview);
$this->assertEquals(true, $preview->valid());

Expand Down
Loading