function ComponentValidatorTest::dataProviderValidatePropsInvalid
Same name in this branch
- 11.x core/modules/sdc/tests/src/Unit/ComponentValidatorTest.php \Drupal\Tests\sdc\Unit\ComponentValidatorTest::dataProviderValidatePropsInvalid()
Same name in other branches
- 10 core/modules/sdc/tests/src/Unit/ComponentValidatorTest.php \Drupal\Tests\sdc\Unit\ComponentValidatorTest::dataProviderValidatePropsInvalid()
- 10 core/tests/Drupal/Tests/Core/Theme/Component/ComponentValidatorTest.php \Drupal\Tests\Core\Theme\Component\ComponentValidatorTest::dataProviderValidatePropsInvalid()
Data provider with invalid component props.
Return value
array Returns the generator with the invalid properties.
File
-
core/
tests/ Drupal/ Tests/ Core/ Theme/ Component/ ComponentValidatorTest.php, line 181
Class
- ComponentValidatorTest
- Unit tests for the component validation.
Namespace
Drupal\Tests\Core\Theme\ComponentCode
public static function dataProviderValidatePropsInvalid() : array {
return [
'missing required prop' => [
[
'href' => 'https://www.drupal.org',
'target' => '_blank',
'attributes' => new Attribute([
'key' => 'value',
]),
],
'my-cta',
static::loadComponentDefinitionFromFs('my-cta'),
'[sdc_test:my-cta/text] The property text is required.',
],
'attributes with invalid object class' => [
[
'text' => 'Can Pica',
'href' => 'https://www.drupal.org',
'target' => '_blank',
'attributes' => new \stdClass(),
],
'my-cta',
static::loadComponentDefinitionFromFs('my-cta'),
'Data provided to prop "attributes" for component "sdc_test:my-cta" is not a valid instance of "Drupal\\Core\\Template\\Attribute"',
],
'ctaTarget violates the allowed properties in the enum' => [
[
'ctaTarget' => 'foo',
],
'my-banner',
static::loadComponentDefinitionFromFs('my-banner'),
'[sdc_test:my-banner/ctaTarget] Does not have a value in the enumeration ["","_blank"]. The provided value is: "foo".',
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.