ResponsiveImageUpdateTest.php in Drupal 8
File
core/modules/responsive_image/tests/src/Functional/Update/ResponsiveImageUpdateTest.php
View source
<?php
namespace Drupal\Tests\responsive_image\Functional\Update;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Core\Serialization\Yaml;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
class ResponsiveImageUpdateTest extends UpdatePathTestBase {
public function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz',
__DIR__ . '/../../../fixtures/update/drupal-8.responsive_image-enabled.php',
];
}
public function testPostUpdateDependency() {
$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);
$options = [
'type' => 'responsive_image',
'label' => 'hidden',
'settings' => [
'responsive_image_style' => 'wide',
'image_link' => '',
],
'third_party_settings' => [],
];
$display = $this
->config('core.entity_view_display.node.article.default');
$display
->set('content.field_image', $options)
->save(TRUE);
$dependencies = $display
->get('dependencies.config') ?: [];
$this
->assertFalse(in_array('responsive_image.styles.wide', $dependencies));
$this
->runUpdates();
$view_display = EntityViewDisplay::load('node.article.default');
$dependencies = $view_display
->getDependencies() + [
'config' => [],
];
$this
->assertTrue(in_array('responsive_image.styles.wide', $dependencies['config']));
}
}