diff --git a/core/modules/config/src/Tests/AssertConfigEntityImportTrait.php b/core/modules/config/src/Tests/AssertConfigEntityImportTrait.php index 044144483a..c150e7ed2b 100644 --- a/core/modules/config/src/Tests/AssertConfigEntityImportTrait.php +++ b/core/modules/config/src/Tests/AssertConfigEntityImportTrait.php @@ -2,36 +2,16 @@ namespace Drupal\config\Tests; -use Drupal\Core\Config\Entity\ConfigEntityInterface; +@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); /** * Provides test assertions for testing config entity synchronization. * - * 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 { - /** - * Asserts that a config entity can be imported without changing it. - * - * @param \Drupal\Core\Config\Entity\ConfigEntityInterface $entity - * The config entity to test importing. - */ - public function assertConfigEntityImport(ConfigEntityInterface $entity) { - // Save original config information. - $entity_uuid = $entity->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::entityManager()->loadEntityByUuid($entity_type_id, $entity_uuid); - $this->assertIdentical($original_data, $imported_entity->toArray()); - } + use \Drupal\Tests\config\Traits\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..e83bedc651 --- /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::entityManager()->loadEntityByUuid($entity_type_id, $entity_uuid); + $this->assertIdentical($original_data, $imported_entity->toArray()); + } + +} diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php index 56484705e1..ea65c4b931 100644 --- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php @@ -3,11 +3,11 @@ namespace Drupal\Tests\field\Functional\EntityReference; use Drupal\Component\Utility\SafeMarkup; -use Drupal\config\Tests\AssertConfigEntityImportTrait; use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\Tests\BrowserTestBase; use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait; +use Drupal\Tests\config\Traits\AssertConfigEntityImportTrait; /** * Tests various Entity reference UI components.