Skip to content

Commit cc0e21f

Browse files
committed
test: refactor ImageMagickHandlerTest
1 parent ffb2027 commit cc0e21f

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

tests/system/Images/ImageMagickHandlerTest.php

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
* @internal
3131
*
3232
* @group Others
33+
*
34+
* @requires extension imagick
3335
*/
3436
final class ImageMagickHandlerTest extends CIUnitTestCase
3537
{
@@ -40,10 +42,6 @@ final class ImageMagickHandlerTest extends CIUnitTestCase
4042

4143
protected function setUp(): void
4244
{
43-
if (! extension_loaded('imagick')) {
44-
$this->markTestSkipped('The ImageMagick extension is not available.');
45-
}
46-
4745
$this->root = WRITEPATH . 'cache/';
4846

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

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

58-
$handlerConfig = new Images();
59-
if (is_file('/usr/bin/convert')) {
60-
$handlerConfig->libraryPath = '/usr/bin/convert';
56+
// get our locally available `convert`
57+
$config = new Images();
58+
$found = false;
59+
60+
foreach ([
61+
'/usr/bin/convert',
62+
trim((string) shell_exec('which convert')),
63+
$config->libraryPath,
64+
] as $convert) {
65+
if (is_file($convert)) {
66+
$config->libraryPath = $convert;
67+
68+
$found = true;
69+
break;
70+
}
71+
}
72+
73+
if (! $found) {
74+
$this->markTestSkipped('Cannot test imagick as there is no available convert program.');
6175
}
62-
$this->handler = Services::image('imagick', $handlerConfig, false);
76+
77+
$this->handler = Services::image('imagick', $config, false);
6378
}
6479

6580
public function testGetVersion(): void

0 commit comments

Comments
 (0)