Same filename and directory in other branches
- 8.9.x core/modules/config/tests/src/Traits/AssertConfigEntityImportTrait.php
- 9 core/modules/config/tests/src/Traits/AssertConfigEntityImportTrait.php
Namespace
Drupal\Tests\config\Traits
File
core/modules/config/tests/src/Traits/AssertConfigEntityImportTrait.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\config\Traits;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
trait AssertConfigEntityImportTrait {
public function assertConfigEntityImport(ConfigEntityInterface $entity) {
$entity_uuid = $entity
->uuid();
$entity_type_id = $entity
->getEntityTypeId();
$original_data = $entity
->toArray();
$this
->copyConfig(\Drupal::service('config.storage'), \Drupal::service('config.storage.sync'));
$entity
->delete();
$this
->configImporter()
->reset()
->import();
$imported_entity = \Drupal::service('entity.repository')
->loadEntityByUuid($entity_type_id, $entity_uuid);
$this
->assertSame($original_data, $imported_entity
->toArray());
}
}
Traits