public function ImageStyleQualityTest::testImageQuality in Image Style Quality 8
Test the image quality is reduced using the plugin.
@dataProvider imageQualityTestCases
File
- tests/
src/ Kernel/ ImageStyleQualityTest.php, line 65
Class
- ImageStyleQualityTest
- Test the image styles.
Namespace
Drupal\Tests\image_style_quality\KernelCode
public function testImageQuality($toolkit) {
$this
->config('system.image')
->set('toolkit', $toolkit)
->save();
$style = ImageStyle::load($this->styleName);
$original_uri = __DIR__ . '/../../fixtures/original.jpg';
$derivative_uri = 'public://test-image.jpg';
$style
->createDerivative($original_uri, $derivative_uri);
// Ensure the generated image is at least half the size of the original.
$this
->assertTrue(filesize($original_uri) > filesize($derivative_uri) * 2);
}