function ComponentRenderTest::checkNonExistingComponent

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

Ensures that including an invalid component creates an error.

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

File

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

Class

ComponentRenderTest
Tests the correct rendering of components.

Namespace

Drupal\KernelTests\Components

Code

protected function checkNonExistingComponent() : void {
    $build = [
        '#type' => 'inline_template',
        '#context' => [],
        '#template' => "{{ include('sdc_test:INVALID', with_context = false) }}",
    ];
    try {
        $this->renderComponentRenderArray($build);
        $this->fail('Invalid prop did not cause an exception');
    } catch (\Throwable $e) {
        $this->addToAssertionCount(1);
    }
}

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