StripMetadataTest.php in Image Effects 8.3
File
tests/src/Functional/Effect/StripMetadataTest.php
View source
<?php
namespace Drupal\Tests\image_effects\Functional\Effect;
use Drupal\Tests\image_effects\Functional\ImageEffectsTestBase;
class StripMetadataTest extends ImageEffectsTestBase {
public function testStripMetadataEffect($toolkit_id, $toolkit_config, array $toolkit_settings) {
$this
->changeToolkit($toolkit_id, $toolkit_config, $toolkit_settings);
$effect = [
'id' => 'image_effects_strip_metadata',
];
$this
->addEffectToTestStyle($effect);
$test_data = [
[
'test_file' => $this
->getTestImageCopyUri('/tests/images/portrait-painting.jpg', 'image_effects'),
'original_orientation' => 8,
],
[
'test_file' => $this
->getTestImageCopyUri('core/tests/fixtures/files/image-test.jpg'),
'original_orientation' => NULL,
],
[
'test_file' => $this
->getTestImageCopyUri('core/tests/fixtures/files/image-1.png'),
'original_orientation' => NULL,
],
];
foreach ($test_data as $data) {
$original_uri = $data['test_file'];
$derivative_uri = $this->testImageStyle
->buildUri($original_uri);
$exif = @exif_read_data(\Drupal::service('file_system')
->realpath($original_uri));
$this
->assertEquals($data['original_orientation'], isset($exif['Orientation']) ? $exif['Orientation'] : NULL);
$this->testImageStyle
->createDerivative($original_uri, $derivative_uri);
$exif = @exif_read_data(\Drupal::service('file_system')
->realpath($derivative_uri));
$this
->assertEquals(NULL, isset($exif['Orientation']) ? $exif['Orientation'] : NULL);
}
}
}