function EntityBundleExistsConstraintValidatorTest::testEntityTypeIdIsStatic
Same name in other branches
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityBundleExistsConstraintValidatorTest.php \Drupal\KernelTests\Core\Entity\EntityBundleExistsConstraintValidatorTest::testEntityTypeIdIsStatic()
Tests validating a bundle of a known (static) entity type ID.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityBundleExistsConstraintValidatorTest.php, line 56
Class
- EntityBundleExistsConstraintValidatorTest
- @group Entity @group Validation
Namespace
Drupal\KernelTests\Core\EntityCode
public function testEntityTypeIdIsStatic() : void {
$definition = DataDefinition::create('string')->addConstraint('EntityBundleExists', 'entity_test_with_bundle');
$violations = $this->container
->get('typed_data_manager')
->create($definition, 'bar')
->validate();
$this->assertCount(1, $violations);
$this->assertSame("The 'bar' bundle does not exist on the 'entity_test_with_bundle' entity type.", (string) $violations->get(0)
->getMessage());
$this->assertSame('', $violations->get(0)
->getPropertyPath());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.