function BundleClassTest::testBundleClassShouldExtendEntityClass

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

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',
    ]);
}

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