function WildcardConfigActionsTest::testCreateForEachWithLabel

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Recipe/WildcardConfigActionsTest.php \Drupal\KernelTests\Core\Recipe\WildcardConfigActionsTest::testCreateForEachWithLabel()

Tests using the `%label` placeholder with the createForEach action.

File

core/tests/Drupal/KernelTests/Core/Recipe/WildcardConfigActionsTest.php, line 202

Class

WildcardConfigActionsTest
Tests config actions targeting multiple entities using wildcards.

Namespace

Drupal\KernelTests\Core\Recipe

Code

public function testCreateForEachWithLabel() : void {
  $this->enableModules([
    'image',
  ]);
  // We should be able to use the `%label` placeholder.
  // Also ensure nested and non-string keys/values are handled correctly.
  $this->container
    ->get('plugin.manager.config_action')
    ->applyAction('createForEach', 'node.type.*', [
    'image.style.node_%bundle_big' => [
      'label' => 'Big image for %label content',
      'effects' => [
        [
          'id' => 'image_scale',
          'weight' => 10,
        ],
      ],
    ],
  ]);
  $this->assertSame('Big image for Type A content', ImageStyle::load('node_one_big')?->label());
  $this->assertSame('Big image for Type B content', ImageStyle::load('node_two_big')?->label());
}

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