function FieldConfigValidationTest::testInvalidDependencies
Same name in other branches
- 10 core/modules/field/tests/src/Kernel/Entity/FieldConfigValidationTest.php \Drupal\Tests\field\Kernel\Entity\FieldConfigValidationTest::testInvalidDependencies()
Tests that validation fails if config dependencies are invalid.
File
-
core/
modules/ field/ tests/ src/ Kernel/ Entity/ FieldConfigValidationTest.php, line 46
Class
- FieldConfigValidationTest
- Tests validation of field_config entities.
Namespace
Drupal\Tests\field\Kernel\EntityCode
public function testInvalidDependencies() : void {
// Remove the config dependencies from the field entity.
$dependencies = $this->entity
->getDependencies();
$dependencies['config'] = [];
$this->entity
->set('dependencies', $dependencies);
$this->assertValidationErrors([
'' => 'This field requires a field storage.',
]);
// Things look sort-of like `field.storage.*.*` should fail validation
// because they don't exist.
$dependencies['config'] = [
'field.storage.fake',
'field.storage.',
'field.storage.user.',
];
$this->entity
->set('dependencies', $dependencies);
$this->assertValidationErrors([
'dependencies.config.0' => "The 'field.storage.fake' config does not exist.",
'dependencies.config.1' => "The 'field.storage.' config does not exist.",
'dependencies.config.2' => "The 'field.storage.user.' config does not exist.",
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.