class ContentEntityStorageBaseTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Entity/ContentEntityStorageBaseTest.php \Drupal\KernelTests\Core\Entity\ContentEntityStorageBaseTest
- 10 core/tests/Drupal/KernelTests/Core/Entity/ContentEntityStorageBaseTest.php \Drupal\KernelTests\Core\Entity\ContentEntityStorageBaseTest
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/ContentEntityStorageBaseTest.php \Drupal\KernelTests\Core\Entity\ContentEntityStorageBaseTest
@coversDefaultClass \Drupal\Core\Entity\ContentEntityStorageBase
@group Entity
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \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 extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Entity\ContentEntityStorageBaseTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ContentEntityStorageBaseTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ ContentEntityStorageBaseTest.php, line 12
Namespace
Drupal\KernelTests\Core\EntityView source
class ContentEntityStorageBaseTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'entity_test',
'user',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('entity_test');
$this->installEntitySchema('user');
}
/**
* @covers ::create
*
* @dataProvider providerTestCreate
*/
public function testCreate($bundle) {
$storage = $this->container
->get('entity_type.manager')
->getStorage('entity_test');
$entity = $storage->create([
'type' => $bundle,
]);
$this->assertEquals('test_bundle', $entity->bundle());
}
/**
* Provides test data for testCreate().
*/
public function providerTestCreate() {
return [
[
'scalar' => 'test_bundle',
],
[
'array keyed by delta' => [
0 => [
'value' => 'test_bundle',
],
],
],
[
'array keyed by main property name' => [
'value' => 'test_bundle',
],
],
];
}
/**
* @covers ::create
*/
public function testReCreate() {
$storage = $this->container
->get('entity_type.manager')
->getStorage('entity_test');
$values = $storage->create([
'type' => 'test_bundle',
])
->toArray();
$entity = $storage->create($values);
$this->assertEquals('test_bundle', $entity->bundle());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.