function ComponentRenderInvalidTest::testInvalidDefinitionTheme

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

Ensure that components in modules without schema fail validation.

The theme sdc_theme_test_enforce_schema_invalid is set as enforcing schemas but provides a component without schema.

File

core/tests/Drupal/KernelTests/Components/ComponentRenderInvalidTest.php, line 44

Class

ComponentRenderInvalidTest
Tests invalid render options for components.

Namespace

Drupal\KernelTests\Components

Code

public function testInvalidDefinitionTheme() : void {
    \Drupal::service('theme_installer')->install([
        'sdc_theme_test_enforce_schema_invalid',
    ]);
    $active_theme = \Drupal::service('theme.initialization')->initTheme('sdc_theme_test_enforce_schema_invalid');
    \Drupal::service('theme.manager')->setActiveTheme($active_theme);
    $this->expectException(InvalidComponentException::class);
    $this->manager
        ->getDefinitions();
}

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