You are here

public function BundleClassTest::testBundleClassShouldExtendEntityClass in Drupal 10

Checks exception thrown if a bundle class doesn't extend the entity class.

File

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

Class

BundleClassTest
Tests entity bundle classes.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testBundleClassShouldExtendEntityClass() {
  $this->container
    ->get('state')
    ->set('entity_test_bundle_class_non_inheriting', TRUE);
  $this->entityTypeManager
    ->clearCachedDefinitions();
  $this
    ->expectException(BundleClassInheritanceException::class);
  entity_test_create_bundle('bundle_class');
  $this->storage
    ->create([
    'type' => 'bundle_class',
  ]);
}