You are here

protected function MigrateImageStylesTest::assertEntity in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php \Drupal\Tests\image\Kernel\Migrate\d7\MigrateImageStylesTest::assertEntity()
  2. 9 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
Tests 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(string $id, string $label, array $expected_effect_plugins, array $expected_effect_config) : void {
  $style = ImageStyle::load($id);
  $this
    ->assertInstanceOf(ImageStyleInterface::class, $style);

  /** @var \Drupal\image\ImageStyleInterface $style */
  $this
    ->assertSame($id, $style
    ->id());
  $this
    ->assertSame($label, $style
    ->label());

  // Check the number of effects associated with the style.
  $effects = $style
    ->getEffects();
  $this
    ->assertSameSize($expected_effect_plugins, $effects);
  $index = 0;
  foreach ($effects as $effect) {
    $this
      ->assertInstanceOf(ImageEffectBase::class, $effect);
    $this
      ->assertSame($expected_effect_plugins[$index], $effect
      ->getPluginId());
    $config = $effect
      ->getConfiguration();
    $this
      ->assertSame($expected_effect_config[$index], $config['data']);
    $index++;
  }
}