class EntityBaseTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityBaseTest.php \Drupal\KernelTests\Core\Entity\EntityBaseTest
- 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
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses \Drupal\Tests\user\Traits\UserCreationTrait implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\Core\Entity\EntityBaseTest implements \Drupal\KernelTests\Core\Entity\EntityKernelTestBase
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses \Drupal\Tests\user\Traits\UserCreationTrait implements \Drupal\KernelTests\KernelTestBase
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());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.