function ImageEffectsTest::testImageStyleEffectDependencyRemoval
Tests uninstalling the module of an effect in a style.
File
-
core/
modules/ image/ tests/ src/ Kernel/ ImageEffectsTest.php, line 276
Class
- ImageEffectsTest
- Tests image effects.
Namespace
Drupal\Tests\image\KernelCode
public function testImageStyleEffectDependencyRemoval() : void {
/** @var \Drupal\image\ImageStyleInterface $image_style */
$image_style = ImageStyle::create([
'name' => 'foo',
'label' => 'Foo',
]);
$image_style->addImageEffect([
'id' => 'image_module_test_null',
'weight' => 0,
]);
$image_style->addImageEffect([
'id' => 'image_scale',
'weight' => 1,
]);
$image_style->save();
$this->assertCount(2, $image_style->getEffects());
// Uninstall the module that provides the 'image_module_test_null' effect.
\Drupal::service('module_installer')->uninstall([
'image_module_test',
]);
// Confirm that image style was not deleted and the dependency on the
// 'image_module_test' module was handled by removing the
// 'image_module_test_null' effect.
$image_style = ImageStyle::load('foo');
$this->assertNotNull($image_style);
$this->assertCount(1, $image_style->getEffects());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.