X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Ffield%2Ftests%2Fsrc%2FKernel%2FFieldImportDeleteTest.php;fp=web%2Fcore%2Fmodules%2Ffield%2Ftests%2Fsrc%2FKernel%2FFieldImportDeleteTest.php;h=f3408a52a0dc9d113308eae5d2b6b7541e9047ac;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=0eef137165a18daec896e93f0533b1d565ac6a69;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/web/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php b/web/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php index 0eef13716..f3408a52a 100644 --- a/web/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php +++ b/web/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\field\Kernel; use Drupal\Component\Utility\SafeMarkup; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -50,6 +51,14 @@ class FieldImportDeleteTest extends FieldKernelTestBase { $field_config_name_2a = "field.field.$field_id_2a"; $field_config_name_2b = "field.field.$field_id_2b"; + // Create an entity with data in the first field to make sure that field + // needs to be purged. + $entity_test = EntityTest::create([ + 'type' => 'entity_test', + ]); + $entity_test->set($field_name, 'test data'); + $entity_test->save(); + // Create a second bundle for the 'Entity test' entity type. entity_test_create_bundle('test_bundle'); @@ -97,10 +106,10 @@ class FieldImportDeleteTest extends FieldKernelTestBase { $this->assertIdentical($active->listAll($field_config_name_2a), []); $this->assertIdentical($active->listAll($field_config_name_2b), []); - // Check that the storage definition is preserved in state. + // Check that only the first storage definition is preserved in state. $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: []; $this->assertTrue(isset($deleted_storages[$field_storage_uuid])); - $this->assertTrue(isset($deleted_storages[$field_storage_uuid_2])); + $this->assertFalse(isset($deleted_storages[$field_storage_uuid_2])); // Purge field data, and check that the storage definition has been // completely removed once the data is purged.