public function BundleClassTest::testAmbiguousBundleClassExceptionEntityTypeRepository in Drupal 10
Checks exception is thrown if two entity types share the same bundle class.
@covers Drupal\Core\Entity\EntityTypeRepository::getEntityTypeFromClass
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ BundleClassTest.php, line 232
Class
- BundleClassTest
- Tests entity bundle classes.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testAmbiguousBundleClassExceptionEntityTypeRepository() {
$this->container
->get('state')
->set('entity_test_bundle_class_enable_ambiguous_entity_types', TRUE);
entity_test_create_bundle('entity_test_no_label');
entity_test_create_bundle('entity_test_no_label', NULL, 'entity_test_no_label');
// Now that we have an entity bundle class that's shared by two entirely
// different entity types, we expect an exception to be thrown.
$this
->expectException(AmbiguousBundleClassException::class);
$entity_type = $this->container
->get('entity_type.repository')
->getEntityTypeFromClass(EntityTestAmbiguousBundleClass::class);
}