You are here

class EntityBaseTest in Drupal 10

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());
  }

}

Members