Skip to content
Snippets Groups Projects
Commit 3c5152d3 authored by Adam G-H's avatar Adam G-H
Browse files

Add a test that all image styles convert to WebP.

parent 4ec07821
No related branches found
No related tags found
No related merge requests found
Pipeline #413534 failed
......@@ -103,7 +103,8 @@
},
"require-dev": {
"drupal/core-dev": "^11.1.1",
"drupal/default_content": "^2"
"drupal/default_content": "^2",
"symfony/polyfill-php84": "*"
},
"autoload-dev": {
"files": [
......
......@@ -5,6 +5,8 @@ declare(strict_types=1);
namespace Drupal\Tests\drupal_cms_image\Functional;
use Drupal\FunctionalTests\Core\Recipe\RecipeTestTrait;
use Drupal\image\Entity\ImageStyle;
use Drupal\image\ImageStyleInterface;
use Drupal\Tests\BrowserTestBase;
/**
......@@ -26,6 +28,23 @@ class ComponentValidationTest extends BrowserTestBase {
$this->applyRecipe($dir);
// Apply it again to prove that it is idempotent.
$this->applyRecipe($dir);
$image_styles = ImageStyle::loadMultiple();
$predicate = function (ImageStyleInterface $image_style): bool {
foreach ($image_style->getEffects() as $effect) {
if ($effect->getPluginId() === 'image_convert') {
$configuration = $effect->getConfiguration();
if ($configuration['extension'] === 'webp') {
return TRUE;
}
}
}
return FALSE;
};
$this->assertTrue(
array_all($image_styles, $predicate),
'Not all image styles include a conversion to WebP.',
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment