You are here

public function BundleClassTest::testAmbiguousBundleClassExceptionCreate in Drupal 10

Checks exception is thrown if two bundles share the same bundle class.

@covers Drupal\Core\Entity\ContentEntityStorageBase::create

File

core/tests/Drupal/KernelTests/Core/Entity/BundleClassTest.php, line 215

Class

BundleClassTest
Tests entity bundle classes.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testAmbiguousBundleClassExceptionCreate() {
  $this->container
    ->get('state')
    ->set('entity_test_bundle_class_enable_ambiguous_entity_types', TRUE);
  $this->entityTypeManager
    ->clearCachedDefinitions();
  entity_test_create_bundle('bundle_class');
  entity_test_create_bundle('bundle_class_2');

  // Since we now have two bundles trying to reuse the same class, we expect
  // this to throw an exception.
  $this
    ->expectException(AmbiguousBundleClassException::class);
  EntityTestBundleClass::create();
}