You are here

protected function ConfigEntityImportTest::doImageStyleUpdate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/ConfigEntityImportTest.php \Drupal\system\Tests\Entity\ConfigEntityImportTest::doImageStyleUpdate()

Tests updating an image style during import.

1 call to ConfigEntityImportTest::doImageStyleUpdate()
ConfigEntityImportTest::testConfigUpdateImport in core/modules/system/src/Tests/Entity/ConfigEntityImportTest.php
Runs test methods for each module within a single test run.

File

core/modules/system/src/Tests/Entity/ConfigEntityImportTest.php, line 122
Contains \Drupal\system\Tests\Entity\ConfigEntityImportTest.

Class

ConfigEntityImportTest
Tests ConfigEntity importing.

Namespace

Drupal\system\Tests\Entity

Code

protected function doImageStyleUpdate() {

  // Create a test image style with a known label.
  $name = 'image.style.thumbnail';

  /** @var $entity \Drupal\image\Entity\ImageStyle */
  $entity = ImageStyle::load('thumbnail');
  $plugin_collection = $entity
    ->getPluginCollections()['effects'];
  $effects = $entity
    ->get('effects');
  $effect_id = key($effects);
  $this
    ->assertIdentical(100, $effects[$effect_id]['data']['height']);
  $effects[$effect_id]['data']['height'] = 50;
  $entity
    ->set('effects', $effects);
  $entity
    ->save();

  // Ensure the entity and plugin have the correct configuration.
  $this
    ->assertIdentical($effects, $entity
    ->get('effects'));
  $this
    ->assertIdentical($effects, $plugin_collection
    ->getConfiguration());
  $effects[$effect_id]['data']['height'] = -50;
  $entity
    ->getPluginCollections()['effects']
    ->setConfiguration($effects);
  $entity
    ->save();

  // Ensure the entity and plugin have the correct configuration.
  $this
    ->assertIdentical($effects, $entity
    ->get('effects'));
  $this
    ->assertIdentical($effects, $plugin_collection
    ->getConfiguration());

  // Read the existing data, and prepare an altered version in sync.
  $custom_data = $original_data = $this->container
    ->get('config.storage')
    ->read($name);
  $effect_name = key($original_data['effects']);
  $custom_data['effects'][$effect_name]['data']['upscale'] = FALSE;
  $this
    ->assertConfigUpdateImport($name, $original_data, $custom_data);
}