diff --git a/core/modules/config/src/Tests/AssertConfigEntityImportTrait.php b/core/modules/config/src/Tests/AssertConfigEntityImportTrait.php index 044144483a..93ec172683 100644 --- a/core/modules/config/src/Tests/AssertConfigEntityImportTrait.php +++ b/core/modules/config/src/Tests/AssertConfigEntityImportTrait.php @@ -2,6 +2,8 @@ namespace Drupal\config\Tests; +@trigger_error('The ' . __NAMESPACE__ . '\AssertConfigEntityImportTrait is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\config\Traits\AssertConfigEntityImportTrait', E_USER_DEPRECATED); + use Drupal\Core\Config\Entity\ConfigEntityInterface; /** @@ -9,6 +11,9 @@ * * Can be used by test classes that extend \Drupal\simpletest\WebTestBase or * \Drupal\KernelTests\KernelTestBase. + * + * @deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0. + * Use \Drupal\Tests\config\Traits\AssertConfigEntityImportTrait. */ trait AssertConfigEntityImportTrait { diff --git a/core/modules/config/tests/src/Traits/AssertConfigEntityImportTrait.php b/core/modules/config/tests/src/Traits/AssertConfigEntityImportTrait.php new file mode 100644 index 0000000000..be5cf6405f --- /dev/null +++ b/core/modules/config/tests/src/Traits/AssertConfigEntityImportTrait.php @@ -0,0 +1,37 @@ +uuid(); + $entity_type_id = $entity->getEntityTypeId(); + $original_data = $entity->toArray(); + // Copy everything to sync. + $this->copyConfig(\Drupal::service('config.storage'), \Drupal::service('config.storage.sync')); + // Delete the configuration from active. Don't worry about side effects of + // deleting config like fields cleaning up field storages. The coming import + // should recreate everything as necessary. + $entity->delete(); + $this->configImporter()->reset()->import(); + $imported_entity = \Drupal::service('entity.repository')->loadEntityByUuid($entity_type_id, $entity_uuid); + $this->assertIdentical($original_data, $imported_entity->toArray()); + } + +}