function ConfigEntityImportTest::doImageStyleUpdate

Same name in other branches
  1. 9 core/modules/system/tests/src/Kernel/Entity/ConfigEntityImportTest.php \Drupal\Tests\system\Kernel\Entity\ConfigEntityImportTest::doImageStyleUpdate()
  2. 8.9.x core/modules/system/tests/src/Kernel/Entity/ConfigEntityImportTest.php \Drupal\Tests\system\Kernel\Entity\ConfigEntityImportTest::doImageStyleUpdate()
  3. 11.x core/modules/system/tests/src/Kernel/Entity/ConfigEntityImportTest.php \Drupal\Tests\system\Kernel\Entity\ConfigEntityImportTest::doImageStyleUpdate()

Tests updating an image style during import.

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

File

core/modules/system/tests/src/Kernel/Entity/ConfigEntityImportTest.php, line 133

Class

ConfigEntityImportTest
Tests ConfigEntity importing.

Namespace

Drupal\Tests\system\Kernel\Entity

Code

protected function doImageStyleUpdate() {
    // Create a test image style with a known label.
    $name = 'image.style.thumbnail';
    
    /** @var \Drupal\image\Entity\ImageStyle $entity */
    $entity = ImageStyle::load('thumbnail');
    $plugin_collection = $entity->getPluginCollections()['effects'];
    $effects = $entity->get('effects');
    $effect_id = key($effects);
    $this->assertSame(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->assertSame($effects, $entity->get('effects'));
    $this->assertSame($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->assertSame($effects, $entity->get('effects'));
    $this->assertSame($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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.