protected function ImageEffectsTestBase::addEffectToTestStyle in Image Effects 8.3
Same name and namespace in other branches
- 8 tests/src/Functional/ImageEffectsTestBase.php \Drupal\Tests\image_effects\Functional\ImageEffectsTestBase::addEffectToTestStyle()
- 8.2 tests/src/Functional/ImageEffectsTestBase.php \Drupal\Tests\image_effects\Functional\ImageEffectsTestBase::addEffectToTestStyle()
Add an image effect to the image test style.
Uses the image effect configuration forms, and not API directly, to ensure forms work correctly.
Parameters
array $effect: An array of effect data, with following keys:
- id: the image effect plugin
- data: an array of fields for the image effect edit form, with their values.
Return value
string The UUID of the newly added effect.
30 calls to ImageEffectsTestBase::addEffectToTestStyle()
- AspectSwitcherTest::testAspectSwitcherEffect in tests/
src/ Functional/ Effect/ AspectSwitcherTest.php - AspectSwitcher effect test.
- AutoOrientTest::testAutoOrientAllTags in tests/
src/ Functional/ Effect/ AutoOrientTest.php - Auto Orientation effect test, all EXIF orientation tags.
- AutoOrientTest::testAutoOrientEffect in tests/
src/ Functional/ Effect/ AutoOrientTest.php - Auto Orientation effect test.
- BackgroundTest::testBackgroundEffect in tests/
src/ Functional/ Effect/ BackgroundTest.php - Background effect test.
- BrightnessTest::testBrightnessEffect in tests/
src/ Functional/ Effect/ BrightnessTest.php - Brightness effect test.
File
- tests/
src/ Functional/ ImageEffectsTestBase.php, line 124
Class
- ImageEffectsTestBase
- Base test class for image_effects tests.
Namespace
Drupal\Tests\image_effects\FunctionalCode
protected function addEffectToTestStyle(array $effect) {
// Get image style prior to adding the new effect.
$image_style_pre = ImageStyle::load($this->testImageStyleName);
// Add the effect.
$this
->drupalGet('admin/config/media/image-styles/manage/' . $this->testImageStyleName);
$this
->submitForm([
'new' => $effect['id'],
], 'Add');
if (!empty($effect['data'])) {
$effect_edit = [];
foreach ($effect['data'] as $field => $value) {
$effect_edit['data[' . $field . ']'] = $value;
}
$this
->submitForm($effect_edit, 'Add effect');
}
// Get UUID of newly added effect.
$this->testImageStyle = ImageStyle::load($this->testImageStyleName);
foreach ($this->testImageStyle
->getEffects() as $uuid => $effect) {
if (!$image_style_pre
->getEffects()
->has($uuid)) {
return $uuid;
}
}
return NULL;
}