function ComponentRenderTest::testRenderNonExistingComponent

Ensures that including an invalid component creates an error.

File

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

Class

ComponentRenderTest
Tests the correct rendering of components.

Namespace

Drupal\KernelTests\Components

Code

public function testRenderNonExistingComponent() : 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) {
    $this->addToAssertionCount(1);
  }
}

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