You are here

public function TwigExtensionTest::testRecursiveMergeFilter in Components! 3.x

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/TwigExtensionTest.php \Drupal\Tests\components\Kernel\TwigExtensionTest::testRecursiveMergeFilter()

Ensures the Twig "recursive_merge" filter works inside a Drupal instance.

@covers ::recursiveMergeFilter

@dataProvider providerTestRecursiveMergeFilter

File

tests/src/Kernel/TwigExtensionTest.php, line 53

Class

TwigExtensionTest
@coversDefaultClass \Drupal\components\Template\TwigExtension @group components

Namespace

Drupal\Tests\components\Kernel

Code

public function testRecursiveMergeFilter(string $theme_hook, string $expected) {
  try {
    $element = [
      '#theme' => $theme_hook,
      'list' => [
        '#theme' => 'item_list',
        '#items' => [
          [
            '#type' => 'container',
            '#attributes' => [
              'id' => 'the_element_id',
              'class' => [
                'original-container-class',
              ],
            ],
          ],
        ],
      ],
    ];
    $result = $this
      ->render($element);
  } catch (\Exception $e) {
    $this
      ->fail('No Exception expected; "' . $e
      ->getMessage() . '" thrown during: ' . $this
      ->getName());
  }
  $this
    ->assertStringContainsString($expected, $result);
}