reverted: --- b/core/modules/picture/config/schema/picture.schema.yml +++ a/core/modules/picture/config/schema/picture.schema.yml @@ -37,9 +37,6 @@ langcode: type: string label: 'Default language' - dependencies: - type: config_dependency - label: 'Dependencies' entity_view_display.field.picture: type: entity_field_view_display_base reverted: --- b/core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php +++ a/core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php @@ -8,7 +8,6 @@ namespace Drupal\picture\Entity; use Drupal\Core\Config\Entity\ConfigEntityBase; -use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\picture\PictureMappingInterface; /** @@ -79,21 +78,6 @@ } /** - * {@inheritdoc} - */ - public function calculateDependencies() { - parent::calculateDependencies(); - if (isset($this->breakpointGroup)) { - // @todo Implement getExportProperties() so we do not have reload the - // entity since this property is changed in - // \Drupal\picture\PictureMapping::save(). - $breakpoint_group = \Drupal::entityManager()->getStorageController('breakpoint_group')->load($this->breakpointGroup); - $this->addDependency('entity', $breakpoint_group->getConfigDependencyName()); - } - return $this->dependencies; - } - - /** * Overrides Drupal\Core\Entity::save(). */ public function save() { reverted: --- b/core/modules/picture/tests/Drupal/picture/Tests/PictureMappingEntityTest.php +++ /dev/null @@ -1,138 +0,0 @@ - '', - 'name' => '\Drupal\picture\Entity\PictureMapping unit test', - 'group' => 'Picture', - ); - } - - /** - * {@inheritdoc} - */ - public function setUp() { - $this->entityTypeId = $this->randomName(); - $this->provider = $this->randomName(); - $this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); - $this->entityType->expects($this->any()) - ->method('getProvider') - ->will($this->returnValue($this->provider)); - - $this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface'); - $this->entityManager->expects($this->any()) - ->method('getDefinition') - ->with($this->entityTypeId) - ->will($this->returnValue($this->entityType)); - - $this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface'); - - $this->breakpointGroupId = $this->randomName(9); - $this->breakpointGroup = $this->getMock('Drupal\breakpoint\Entity\BreakpointGroup', array(), array(array('id' => $this->breakpointGroupId))); - - $this->breakpointGroupStorageController = $this->getMock('\Drupal\Core\Config\Entity\ConfigStorageControllerInterface'); - $this->breakpointGroupStorageController - ->expects($this->any()) - ->method('load') - ->with($this->breakpointGroupId) - ->will($this->returnValue($this->breakpointGroup)); - - $this->entityManager->expects($this->any()) - ->method('getStorageController') - ->will($this->returnValue($this->breakpointGroupStorageController)); - - $container = new ContainerBuilder(); - $container->set('entity.manager', $this->entityManager); - $container->set('uuid', $this->uuid); - \Drupal::setContainer($container); - } - - /** - * @covers ::calculateDependencies - */ - public function testCalculateDependencies() { - $picture_mapping = new PictureMapping(array(), $this->entityTypeId); - // Set the breakpoint group after creating the entity to avoid the calls - // in the constructor. - $picture_mapping->breakpointGroup = $this->breakpointGroupId; - $this->breakpointGroup->expects($this->once()) - ->method('getConfigDependencyName') - ->will($this->returnValue('breakpoint.breakpoint_group.' . $this->breakpointGroupId)); - - $dependencies = $picture_mapping->calculateDependencies(); - $this->assertContains('breakpoint.breakpoint_group.' . $this->breakpointGroupId, $dependencies['entity']); - } - -} only in patch2: unchanged: --- a/core/modules/responsive_image/config/schema/responsive_image.schema.yml +++ b/core/modules/responsive_image/config/schema/responsive_image.schema.yml @@ -37,6 +37,9 @@ responsive_image.mappings.*: langcode: type: string label: 'Default language' + dependencies: + type: config_dependency + label: 'Dependencies' entity_view_display.field.responsive_image: type: entity_field_view_display_base only in patch2: unchanged: --- a/core/modules/responsive_image/lib/Drupal/responsive_image/Entity/ResponsiveImageMapping.php +++ b/core/modules/responsive_image/lib/Drupal/responsive_image/Entity/ResponsiveImageMapping.php @@ -78,6 +78,21 @@ public function __construct(array $values, $entity_type) { } /** + * {@inheritdoc} + */ + public function calculateDependencies() { + parent::calculateDependencies(); + if (isset($this->breakpointGroup)) { + // @todo Implement getExportProperties() so we do not have reload the + // entity since this property is changed in + // \Drupal\responsive_image\Entity\ResponsiveImageMapping::save(). + $breakpoint_group = \Drupal::entityManager()->getStorageController('breakpoint_group')->load($this->breakpointGroup); + $this->addDependency('entity', $breakpoint_group->getConfigDependencyName()); + } + return $this->dependencies; + } + + /** * Overrides Drupal\Core\Entity::save(). */ public function save() { only in patch2: unchanged: --- /dev/null +++ b/core/modules/responsive_image/tests/Drupal/responsive_image/Tests/PictureMappingEntityTest.php @@ -0,0 +1,137 @@ + '', + 'name' => '\Drupal\responsive_image\Entity\ResponsiveImageMapping unit test', + 'group' => 'Picture', + ); + } + + /** + * {@inheritdoc} + */ + public function setUp() { + $this->entityTypeId = $this->randomName(); + $this->provider = $this->randomName(); + $this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); + $this->entityType->expects($this->any()) + ->method('getProvider') + ->will($this->returnValue($this->provider)); + + $this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface'); + $this->entityManager->expects($this->any()) + ->method('getDefinition') + ->with($this->entityTypeId) + ->will($this->returnValue($this->entityType)); + + $this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface'); + + $this->breakpointGroupId = $this->randomName(9); + $this->breakpointGroup = $this->getMock('Drupal\breakpoint\Entity\BreakpointGroup', array(), array(array('id' => $this->breakpointGroupId))); + + $this->breakpointGroupStorageController = $this->getMock('\Drupal\Core\Config\Entity\ConfigStorageControllerInterface'); + $this->breakpointGroupStorageController + ->expects($this->any()) + ->method('load') + ->with($this->breakpointGroupId) + ->will($this->returnValue($this->breakpointGroup)); + + $this->entityManager->expects($this->any()) + ->method('getStorageController') + ->will($this->returnValue($this->breakpointGroupStorageController)); + + $container = new ContainerBuilder(); + $container->set('entity.manager', $this->entityManager); + $container->set('uuid', $this->uuid); + \Drupal::setContainer($container); + } + + /** + * @covers ::calculateDependencies + */ + public function testCalculateDependencies() { + $picture_mapping = new ResponsiveImageMapping(array(), $this->entityTypeId); + // Set the breakpoint group after creating the entity to avoid the calls + // in the constructor. + $picture_mapping->breakpointGroup = $this->breakpointGroupId; + $this->breakpointGroup->expects($this->once()) + ->method('getConfigDependencyName') + ->will($this->returnValue('breakpoint.breakpoint_group.' . $this->breakpointGroupId)); + + $dependencies = $picture_mapping->calculateDependencies(); + $this->assertContains('breakpoint.breakpoint_group.' . $this->breakpointGroupId, $dependencies['entity']); + } + +}