function ComponentRenderInvalidTest::testInvalidDefinitionModule

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

Ensure that components in modules without schema fail validation.

The module sdc_test_invalid contains the my-card-no-schema component. This component does not have schema definitions.

File

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

Class

ComponentRenderInvalidTest
Tests invalid render options for components.

Namespace

Drupal\KernelTests\Components

Code

public function testInvalidDefinitionModule() : void {
    $this->expectException(InvalidComponentException::class);
    $this->expectExceptionMessage('The component "sdc_test_invalid:my-card-no-schema" does not provide schema information. Schema definitions are mandatory for components declared in modules. For components declared in themes, schema definitions are only mandatory if the "enforce_prop_schemas" key is set to "true" in the theme info file.');
    $this->manager
        ->getDefinitions();
}

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