function ComponentValidatorTest::dataProviderValidateDefinitionValid
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Theme/Component/ComponentValidatorTest.php \Drupal\Tests\Core\Theme\Component\ComponentValidatorTest::dataProviderValidateDefinitionValid()
- 10 core/tests/Drupal/Tests/Core/Theme/Component/ComponentValidatorTest.php \Drupal\Tests\Core\Theme\Component\ComponentValidatorTest::dataProviderValidateDefinitionValid()
Data provider with valid component definitions.
Return value
array The data.
File
-
core/
tests/ Drupal/ Tests/ Core/ Theme/ Component/ ComponentValidatorTest.php, line 52
Class
- ComponentValidatorTest
- Unit tests for the component validation.
Namespace
Drupal\Tests\Core\Theme\ComponentCode
public static function dataProviderValidateDefinitionValid() : \Generator {
$data = array_map([
static::class,
'loadComponentDefinitionFromFs',
], [
'my-banner',
'my-button',
'my-cta',
]);
foreach ($data as $definition) {
yield [
$definition,
];
}
// Variant names may contain dashes because they are used as string values
// (e.g. CSS modifiers) and are never converted to Twig variable or block
// names, unlike props and slots.
$cta_with_dashed_variant = static::loadComponentDefinitionFromFs('my-cta');
$cta_with_dashed_variant['variants'] = [
'my-variant' => [
'title' => 'My variant',
'description' => 'Variant names with dashes are valid.',
],
];
yield 'variant name with dashes is valid' => [
$cta_with_dashed_variant,
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.