
| Current Path : /var/www/html/stolberg/web/core/tests/Drupal/KernelTests/Components/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/stolberg/web/core/tests/Drupal/KernelTests/Components/ComponentRenderInvalidTest.php |
<?php
declare(strict_types=1);
namespace Drupal\KernelTests\Components;
use Drupal\Core\Render\Component\Exception\InvalidComponentException;
/**
* Tests invalid render options for components.
*
* @group sdc
*/
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();
}
}