class EntityBaseTest in Drupal 10
Tests the functionality provided by \Drupal\Core\Entity\EntityBase.
@coversDefaultClass \Drupal\Core\Entity\EntityBase @group Entity
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, AssertContentTrait, ConfigTestTrait, ExtensionListTestTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses UserCreationTrait
- class \Drupal\KernelTests\Core\Entity\EntityBaseTest
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses UserCreationTrait
Expanded class hierarchy of EntityBaseTest
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityBaseTest.php, line 17
Namespace
Drupal\KernelTests\Core\EntityView 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());
}
}