function BundleClassTest::testBundleClassShouldExist

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

Checks exception thrown if a bundle class doesn't exist.

File

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

Class

BundleClassTest
Tests entity bundle classes.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testBundleClassShouldExist() {
    $this->container
        ->get('state')
        ->set('entity_test_bundle_class_does_not_exist', TRUE);
    $this->entityTypeManager
        ->clearCachedDefinitions();
    $this->expectException(MissingBundleClassException::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.