File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030 * @internal
3131 *
3232 * @group Others
33+ *
34+ * @requires extension imagick
3335 */
3436final 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
You can’t perform that action at this time.
0 commit comments