EntityBaseTest.php in Drupal 10
File
core/tests/Drupal/KernelTests/Core/Entity/EntityBaseTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Entity;
use Drupal\Core\Entity\Plugin\DataType\ConfigEntityAdapter;
use Drupal\Core\Entity\Plugin\DataType\EntityAdapter;
use Drupal\entity_test\Entity\EntityTestBundle;
use Drupal\entity_test\Entity\EntityTestWithBundle;
class EntityBaseTest extends EntityKernelTestBase {
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('entity_test_with_bundle');
}
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());
}
}