Same filename and directory in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Field/MapBaseFieldTest.php
- 9 core/tests/Drupal/KernelTests/Core/Field/MapBaseFieldTest.php
Namespace
Drupal\KernelTests\Core\Field
File
core/tests/Drupal/KernelTests/Core/Field/MapBaseFieldTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\KernelTests\Core\Field;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\entity_test_update\Entity\EntityTestUpdate;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
class MapBaseFieldTest extends EntityKernelTestBase {
protected $entityDefinitionUpdateManager;
protected static $modules = [
'entity_test_update',
];
protected function setUp() : void {
parent::setUp();
$this->entityDefinitionUpdateManager = $this->container
->get('entity.definition_update_manager');
foreach (array_diff_key($this->entityTypeManager
->getDefinitions(), array_flip([
'user',
'entity_test',
])) as $entity_type_id => $entity_type) {
$this
->installEntitySchema($entity_type_id);
}
}
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']);
}
}
Classes