Skip to content
Merged
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
31 changes: 23 additions & 8 deletions tests/system/Images/ImageMagickHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
* @internal
*
* @group Others
*
* @requires extension imagick
*/
final class ImageMagickHandlerTest extends CIUnitTestCase
{
Expand All @@ -40,10 +42,6 @@ final class ImageMagickHandlerTest extends CIUnitTestCase

protected function setUp(): void
{
if (! extension_loaded('imagick')) {
$this->markTestSkipped('The ImageMagick extension is not available.');
}

$this->root = WRITEPATH . 'cache/';

// cleanup everything
Expand All @@ -55,11 +53,28 @@ protected function setUp(): void

$this->path = $this->origin . 'ci-logo.png';

$handlerConfig = new Images();
if (is_file('/usr/bin/convert')) {
$handlerConfig->libraryPath = '/usr/bin/convert';
// get our locally available `convert`
$config = new Images();
$found = false;

foreach ([
'/usr/bin/convert',
trim((string) shell_exec('which convert')),
$config->libraryPath,
] as $convert) {
if (is_file($convert)) {
$config->libraryPath = $convert;

$found = true;
break;
}
}

if (! $found) {
$this->markTestSkipped('Cannot test imagick as there is no available convert program.');
}
$this->handler = Services::image('imagick', $handlerConfig, false);

$this->handler = Services::image('imagick', $config, false);
}

public function testGetVersion(): void
Expand Down