class MapBaseFieldTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Field/MapBaseFieldTest.php \Drupal\KernelTests\Core\Field\MapBaseFieldTest
- 10 core/tests/Drupal/KernelTests/Core/Field/MapBaseFieldTest.php \Drupal\KernelTests\Core\Field\MapBaseFieldTest
- 8.9.x core/tests/Drupal/KernelTests/Core/Field/MapBaseFieldTest.php \Drupal\KernelTests\Core\Field\MapBaseFieldTest
Tests map base fields.
@group Field
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\EntityKernelTestBase uses \Drupal\Tests\user\Traits\UserCreationTrait extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\Core\Field\MapBaseFieldTest extends \Drupal\KernelTests\Core\Entity\EntityKernelTestBase
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses \Drupal\Tests\user\Traits\UserCreationTrait extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of MapBaseFieldTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Field/ MapBaseFieldTest.php, line 14
Namespace
Drupal\KernelTests\Core\FieldView source
class MapBaseFieldTest extends EntityKernelTestBase {
/**
* The entity definition update manager.
*
* @var \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface
*/
protected $entityDefinitionUpdateManager;
/**
* {@inheritdoc}
*/
protected static $modules = [
'entity_test_update',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->entityDefinitionUpdateManager = $this->container
->get('entity.definition_update_manager');
// Install every entity type's schema that wasn't installed in the parent
// method.
foreach (array_diff_key($this->entityTypeManager
->getDefinitions(), array_flip([
'user',
'entity_test',
])) as $entity_type_id => $entity_type) {
$this->installEntitySchema($entity_type_id);
}
}
/**
* Tests uninstalling map item base field.
*/
public function testUninstallMapItemBaseField() {
$definitions['data_map'] = BaseFieldDefinition::create('map')->setLabel(t('Data'))
->setRequired(TRUE);
$this->state
->set('entity_test_update.additional_base_field_definitions', $definitions);
$this->entityDefinitionUpdateManager
->installFieldStorageDefinition('data_map', 'entity_test_update', 'entity_test', $definitions['data_map']);
$entity = EntityTestUpdate::create([
'data_map' => [
'key' => 'value',
],
]);
$entity->save();
$this->entityDefinitionUpdateManager
->uninstallFieldStorageDefinition($definitions['data_map']);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.