You are here

public function BundleClassTest::testEntityClassNotTakenFromActiveDefinitions in Drupal 10

Tests that a module can override an entity-type class.

Ensures a module can implement hook_entity_info_alter() and alter the entity's class without needing to write to the last installed definitions repository.

File

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

Class

BundleClassTest
Tests entity bundle classes.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testEntityClassNotTakenFromActiveDefinitions() : void {
  $this->container
    ->get('state')
    ->set('entity_test_bundle_class_override_base_class', TRUE);
  $this->entityTypeManager
    ->clearCachedDefinitions();
  $this
    ->assertEquals(EntityTestVariant::class, $this->entityTypeManager
    ->getStorage('entity_test')
    ->getEntityClass());
}