You are here

public function ImportExportTestBase::configEntityImportExport in Acquia Content Hub 8.2

Executes the set of import/export tests on a configuration entity.

Parameters

int $delta: Fixture delta.

array $validate_data: Data.

string $export_type: Exported entity type.

string $export_uuid: Entity UUID.

Throws

\Drupal\Core\Entity\EntityStorageException

\Exception

4 calls to ImportExportTestBase::configEntityImportExport()
ConfigEntityImportWithLocalNullUuidTest::testNodeConfigEntity in tests/src/Kernel/ConfigEntityImportWithLocalNullUuidTest.php
Tests View Configuration Entity import/export.
ConfigEntityTranslationTest::testConfigEntityTranslations in tests/src/Kernel/ConfigEntityTranslationTest.php
Tests Configuration Entity translations import/export.
ViewConfigTest::testViewConfigEntity in tests/src/Kernel/ViewConfigTest.php
Tests View Configuration Entity import/export.
WebformImportExportTest::testWebformImportExport in tests/src/Kernel/WebformImportExportTest.php
The webform import export test.

File

tests/src/Kernel/ImportExportTestBase.php, line 210

Class

ImportExportTestBase
Base for testing exports and imports.

Namespace

Drupal\Tests\acquia_contenthub\Kernel

Code

public function configEntityImportExport(int $delta, array $validate_data, $export_type, $export_uuid) {
  $expectations = $this
    ->importFixture($delta);
  foreach ($validate_data as $item) {
    [
      'type' => $type,
      'uuid' => $uuid,
    ] = $item;
    if (!isset($expectations[$uuid])) {
      throw new \Exception(sprintf('You are missing validation for the entity of type %s of uuid %s.', $type, $uuid));
    }

    /** @var \Drupal\Tests\acquia_contenthub\Kernel\Stubs\CdfExpectations $expectation */
    $expectation = $expectations[$uuid];

    /** @var \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Config\Entity\ConfigEntityType $entity */
    $entity = $this
      ->getEntity($type, $uuid, $expectation);

    /** @var \Drupal\Core\Config\Entity\ConfigEntityType $entity_type */
    $entity_type = $entity
      ->getEntityType();
    $config_name = $entity_type
      ->getConfigPrefix() . '.' . $entity
      ->get($entity_type
      ->getKey('id'));

    // Perform assertions against imported configuration entity.
    $this
      ->assertImportedConfigEntity($expectation, $config_name);
  }

  // Perform assertions against exported configuration entities.
  $expectation = $expectations[$export_uuid] ?? NULL;
  $this
    ->assertExportedConfigEntities($delta, $export_type, $export_uuid, $expectation);
}