function EntityBundleEntityTest::testWithConfigBundleEntity

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityBundleEntityTest.php \Drupal\KernelTests\Core\Entity\EntityBundleEntityTest::testWithConfigBundleEntity()

Tests an entity type with config entities for bundles.

@legacy-covers ::getBundleEntity

File

core/tests/Drupal/KernelTests/Core/Entity/EntityBundleEntityTest.php, line 45

Class

EntityBundleEntityTest
Tests the getBundleEntity() method.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testWithConfigBundleEntity() : void {
  $bundleEntity = EntityTestBundle::create([
    'id' => 'bundle_alpha',
    'label' => 'Alpha',
  ]);
  $bundleEntity->save();
  $entity = EntityTestWithBundle::create([
    'type' => 'bundle_alpha',
    'name' => 'foo',
  ]);
  $entity->save();
  $this->assertEquals($bundleEntity->id(), $entity->getBundleEntity()
    ->id());
}

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