diff --git a/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php b/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php index aee5a70..4912a3b 100644 --- a/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php +++ b/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php @@ -8,6 +8,7 @@ namespace Drupal\responsive_image\Entity; use Drupal\Core\Config\Entity\ConfigEntityBase; +use Drupal\image\Entity\ImageStyle; use Drupal\responsive_image\ResponsiveImageStyleInterface; /** @@ -184,6 +185,12 @@ public function calculateDependencies() { foreach ($providers as $provider => $type) { $this->addDependency($type, $provider); } + foreach ($this->getImageStyleMappings() as $mapping) { + $style = ImageStyle::load($mapping['image_style']); + if ($style) { + $this->addDependency('config', $style->getConfigDependencyName()); + } + } return $this->dependencies; } diff --git a/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php b/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php index afbb26f..911d654 100644 --- a/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php +++ b/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php @@ -65,8 +65,33 @@ protected function setUp() { * @covers ::calculateDependencies */ public function testCalculateDependencies() { + // Set up image style loading mock. + $image_style_entity = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityInterface'); + $image_style_entity->expects($this->any()) + ->method('getConfigDependencyName') + ->willReturn('image.style.test_style'); + $storage = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityStorageInterface'); + $storage->expects($this->at(0)) + ->method('load') + ->with('test_style') + ->willReturn($image_style_entity); + $storage->expects($this->at(1)) + ->method('load') + ->with('') + ->willReturn(NULL); + $this->entityManager->expects($this->any()) + ->method('getStorage') + ->with('image_style') + ->willReturn($storage); + $this->entityManager->expects($this->any()) + ->method('getEntityTypeFromClass') + ->with('Drupal\image\Entity\ImageStyle') + ->willReturn('image_style'); + $entity = new ResponsiveImageStyle(array('breakpoint_group' => 'test_group')); $entity->setBreakpointGroup('test_group'); + $entity->addImageStyleMapping('test_breakpoint', '1x', array('image_style'=>'test_style')); + $entity->addImageStyleMapping('test_breakpoint', '2x', array()); $this->breakpointManager->expects($this->any()) ->method('getGroupProviders') @@ -76,6 +101,7 @@ public function testCalculateDependencies() { $dependencies = $entity->calculateDependencies(); $this->assertContains('toolbar', $dependencies['module']); $this->assertContains('bartik', $dependencies['theme']); + $this->assertContains('image.style.test_style', $dependencies['config']); } /**