class EntityBaseTest

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityBaseTest.php \Drupal\KernelTests\Core\Entity\EntityBaseTest
  2. 11.x core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\EntityBaseTest

Tests the functionality provided by \Drupal\Core\Entity\EntityBase.

@coversDefaultClass \Drupal\Core\Entity\EntityBase
@group Entity

Hierarchy

Expanded class hierarchy of EntityBaseTest

File

core/tests/Drupal/KernelTests/Core/Entity/EntityBaseTest.php, line 17

Namespace

Drupal\KernelTests\Core\Entity
View source
class EntityBaseTest extends EntityKernelTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this->installEntitySchema('entity_test_with_bundle');
  }
  
  /**
   * Tests that the correct entity adapter is returned.
   *
   * @covers ::getTypedData
   * @covers ::getClass
   */
  public function testGetTypedData() {
    $bundle = EntityTestBundle::create([
      'id' => $this->randomMachineName(),
    ]);
    $bundle->save();
    $entity = EntityTestWithBundle::create([
      'type' => $bundle->id(),
      'name' => $this->randomString(),
    ]);
    $entity->save();
    $this->assertInstanceOf(ConfigEntityAdapter::class, $bundle->getTypedData());
    $this->assertInstanceOf(EntityAdapter::class, $entity->getTypedData());
  }

}

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