class ComponentRenderInvalidTest

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Components/ComponentRenderInvalidTest.php \Drupal\KernelTests\Components\ComponentRenderInvalidTest

Tests invalid render options for components.

@group sdc

Hierarchy

Expanded class hierarchy of ComponentRenderInvalidTest

File

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

Namespace

Drupal\KernelTests\Components
View source
class ComponentRenderInvalidTest extends ComponentKernelTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'sdc_test_invalid',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected static $themes = [
    'starterkit_theme',
  ];
  
  /**
   * 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.
   */
  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();
  }
  
  /**
   * 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.
   */
  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();
  }

}

Members

Title Sort descending Modifiers Object type Summary
ComponentRenderInvalidTest::$modules protected static property Modules to install.
ComponentRenderInvalidTest::$themes protected static property Themes to install.
ComponentRenderInvalidTest::testInvalidDefinitionModule public function Ensure that components in modules without schema fail validation.
ComponentRenderInvalidTest::testInvalidDefinitionTheme public function Ensure that components in modules without schema fail validation.
ExtensionListTestTrait::getModulePath protected function Gets the path for the specified module.
ExtensionListTestTrait::getThemePath protected function Gets the path for the specified theme.
StorageCopyTrait::replaceStorageContents protected static function Copy the configuration from one storage to another and remove stale items.

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