function BundleClassTest::testEntityNoBundleSubclass

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/BundleClassTest.php \Drupal\KernelTests\Core\Entity\BundleClassTest::testEntityNoBundleSubclass()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/BundleClassTest.php \Drupal\KernelTests\Core\Entity\BundleClassTest::testEntityNoBundleSubclass()

Tests making use of a custom bundle class for an entity without bundles.

File

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

Class

BundleClassTest
Tests entity bundle classes.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testEntityNoBundleSubclass() : void {
    $this->container
        ->get('state')
        ->set('entity_test_bundle_class_enable_user_class', TRUE);
    $this->container
        ->get('kernel')
        ->rebuildContainer();
    $this->entityTypeManager
        ->clearCachedDefinitions();
    $this->drupalSetUpCurrentUser();
    $entity = User::load(1);
    $this->assertInstanceOf(EntityTestUserClass::class, $entity);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.