function MigrateImageStylesTest::assertEntity

Same name and namespace in other branches
  1. 9 core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php \Drupal\Tests\image\Kernel\Migrate\d7\MigrateImageStylesTest::assertEntity()
  2. 10 core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php \Drupal\Tests\image\Kernel\Migrate\d7\MigrateImageStylesTest::assertEntity()
  3. 11.x core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php \Drupal\Tests\image\Kernel\Migrate\d7\MigrateImageStylesTest::assertEntity()

Asserts various aspects of an ImageStyle entity.

Parameters

string $id: The expected image style ID.

string $label: The expected image style label.

array $expected_effect_plugins: An array of expected plugins attached to the image style entity

array $expected_effect_config: An array of expected configuration for each effect in the image style

1 call to MigrateImageStylesTest::assertEntity()
MigrateImageStylesTest::testImageStylesMigration in core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php
Test the image styles migration.

File

core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php, line 52

Class

MigrateImageStylesTest
Test image styles migration to config entities.

Namespace

Drupal\Tests\image\Kernel\Migrate\d7

Code

protected function assertEntity($id, $label, array $expected_effect_plugins, array $expected_effect_config) {
    $style = ImageStyle::load($id);
    $this->assertInstanceOf(ImageStyleInterface::class, $style);
    
    /** @var \Drupal\image\ImageStyleInterface $style */
    $this->assertIdentical($id, $style->id());
    $this->assertIdentical($label, $style->label());
    // Check the number of effects associated with the style.
    $effects = $style->getEffects();
    $this->assertIdentical(count($effects), count($expected_effect_plugins));
    $index = 0;
    foreach ($effects as $effect) {
        $this->assertInstanceOf(ImageEffectBase::class, $effect);
        $this->assertIdentical($expected_effect_plugins[$index], $effect->getPluginId());
        $config = $effect->getConfiguration();
        $this->assertIdentical($expected_effect_config[$index], $config['data']);
        $index++;
    }
}

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