Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactor ImageMagickHandlerTest #8461

Merged
merged 1 commit into from
Jan 27, 2024
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 @@

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 @@

$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 Expand Up @@ -407,7 +422,7 @@
$this->assertSame(exif_imagetype($this->root . 'ci-logo.png'), IMAGETYPE_PNG);
}

public function testImageReorientLandscape(): void

Check warning on line 425 in tests/system/Images/ImageMagickHandlerTest.php

View workflow job for this annotation

GitHub Actions / Others (8.1) / Sanity Tests

Took 0.55s from 0.50s limit to run CodeIgniter\\Images\\ImageMagickHandlerTest::testImageReorientLandscape
{
for ($i = 0; $i <= 8; $i++) {
$source = $this->origin . 'EXIFsamples/landscape_' . $i . '.jpg';
Expand All @@ -426,7 +441,7 @@
}
}

public function testImageReorientPortrait(): void

Check warning on line 444 in tests/system/Images/ImageMagickHandlerTest.php

View workflow job for this annotation

GitHub Actions / Others (8.1) / Sanity Tests

Took 0.55s from 0.50s limit to run CodeIgniter\\Images\\ImageMagickHandlerTest::testImageReorientPortrait
{
for ($i = 0; $i <= 8; $i++) {
$source = $this->origin . 'EXIFsamples/portrait_' . $i . '.jpg';
Expand Down
Loading