function ComponentRenderTest::checkIncludeDataMapping

Same name in this branch
  1. 10 core/modules/sdc/tests/src/Kernel/ComponentRenderTest.php \Drupal\Tests\sdc\Kernel\ComponentRenderTest::checkIncludeDataMapping()
Same name and namespace in other branches
  1. 11.x core/modules/sdc/tests/src/Kernel/ComponentRenderTest.php \Drupal\Tests\sdc\Kernel\ComponentRenderTest::checkIncludeDataMapping()
  2. 11.x core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php \Drupal\KernelTests\Components\ComponentRenderTest::checkIncludeDataMapping()

Check using a component with an include and no default context.

This covers passing a render array to a 'string' prop, and mapping the prop to a context variable.

1 call to ComponentRenderTest::checkIncludeDataMapping()
ComponentRenderTest::testRender in core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php
Test that components render correctly.

File

core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php, line 69

Class

ComponentRenderTest
Tests the correct rendering of components.

Namespace

Drupal\KernelTests\Components

Code

protected function checkIncludeDataMapping() : void {
  $content = [
    'label' => [
      '#type' => 'html_tag',
      '#tag' => 'span',
      '#value' => 'Another button ç',
    ],
  ];
  $build = [
    '#type' => 'inline_template',
    '#context' => [
      'content' => $content,
    ],
    '#template' => "{{ include('sdc_test:my-button', { text: content.label, iconType: 'external' }, with_context = false) }}",
  ];
  $crawler = $this->renderComponentRenderArray($build);
  $this->assertNotEmpty($crawler->filter('#sdc-wrapper button:contains("Another button ç")'));
}

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