diff --git a/core/modules/responsive_image/responsive_image.post_update.php b/core/modules/responsive_image/responsive_image.post_update.php index 73265df..1598c4c 100644 --- a/core/modules/responsive_image/responsive_image.post_update.php +++ b/core/modules/responsive_image/responsive_image.post_update.php @@ -5,25 +5,24 @@ * Post update functions for Responsive Image. */ +use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\Entity\EntityViewDisplay; /** - * @addtogroup updates-8.1.0 + * @addtogroup updates-8.0.x * @{ */ /** * Make responsive image formatters dependent on responsive image styles. */ -function responsive_image_post_update_dependency() { - /** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */ - foreach (EntityViewDisplay::loadMultiple() as $display) { - debug($display->id()); - // Re-save to update dependencies. - $display->save(); - } +function responsive_image_post_update_recreate_dependencies() { + $displays = EntityViewDisplay::loadMultiple(); + array_walk($displays, function(EntityViewDisplayInterface $entity_view_display) { + $entity_view_display->save(); + }); } /** - * @} End of "addtogroup updates-8.1.0". + * @} End of "addtogroup updates-8.0.x". */ diff --git a/core/modules/responsive_image/src/Tests/Update/ResponsiveImageUpdateTest.php b/core/modules/responsive_image/src/Tests/Update/ResponsiveImageUpdateTest.php index 1d3ff1c..2f24c53 100644 --- a/core/modules/responsive_image/src/Tests/Update/ResponsiveImageUpdateTest.php +++ b/core/modules/responsive_image/src/Tests/Update/ResponsiveImageUpdateTest.php @@ -7,6 +7,7 @@ namespace Drupal\responsive_image\Tests\Update; +use Drupal\Component\Serialization\Yaml; use Drupal\Core\Entity\Entity\EntityViewDisplay; use Drupal\system\Tests\Update\UpdatePathTestBase; @@ -27,12 +28,33 @@ public function setDatabaseDumpFiles() { } /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + + /** @var \Drupal\Core\State\StateInterface $state */ + $state = $this->container->get('state'); + + // Enable responsive_image module without using the module installer to + // avoid installation of configurations shipped in module. + $system_module_files = $state->get('system.module.files', []); + $system_module_files += ['responsive_image' => 'core/modules/responsive_image/responsive_image.info.yml']; + $state->set('system.module.files', $system_module_files); + $this->config('core.extension')->set('module.responsive_image', 0)->save(); + $this->container->get('module_handler')->addModule('responsive_image', 'core/modules/responsive_image'); + } + + /** * Tests post-update responsive_image_post_update_dependency(). * * @see responsive_image_post_update_dependency() */ public function testPostUpdateDependency() { - $this->container->get('module_installer')->install(['responsive_image']); + // Installing the 'wide' responsive image style. + $wide_image_style = Yaml::decode(file_get_contents(__DIR__ . '/../../../../../profiles/standard/config/optional/responsive_image.styles.wide.yml')); + $this->config('responsive_image.styles.wide')->setData($wide_image_style)->save(TRUE); + // Change 'field_image' formatter to a responsive image formatter. $options = [ 'type' => 'responsive_image',