You are here

protected function DestinationCategoryTest::assertCategories in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/DestinationCategoryTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\DestinationCategoryTest::assertCategories()

Asserts that all migrations are tagged as either Configuration or Content.

Parameters

\Drupal\migrate\Plugin\MigrationInterface[] $migrations: The migrations.

2 calls to DestinationCategoryTest::assertCategories()
DestinationCategoryTest::testD6Categories in core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/DestinationCategoryTest.php
Tests that all D6 migrations are tagged as either Configuration or Content.
DestinationCategoryTest::testD7Categories in core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/DestinationCategoryTest.php
Tests that all D7 migrations are tagged as either Configuration or Content.

File

core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/DestinationCategoryTest.php, line 71

Class

DestinationCategoryTest
Tests that all migrations are tagged as either content or configuration.

Namespace

Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate

Code

protected function assertCategories($migrations) {
  foreach ($migrations as $id => $migration) {
    $object_classes = class_parents($migration
      ->getDestinationPlugin());
    $object_classes[] = get_class($migration
      ->getDestinationPlugin());

    // Ensure that the destination plugin is an instance of at least one of
    // the expected classes.
    if (in_array('Configuration', $migration
      ->getMigrationTags(), TRUE)) {
      $this
        ->assertNotEmpty(array_intersect($object_classes, $this
        ->getConfigurationClasses()), "The migration {$id} is tagged as Configuration.");
    }
    elseif (in_array('Content', $migration
      ->getMigrationTags(), TRUE)) {
      $this
        ->assertNotEmpty(array_intersect($object_classes, $this
        ->getContentClasses()), "The migration {$id} is tagged as Content.");
    }
    else {
      $this
        ->fail("The migration {$id} is not tagged as either 'Content' or 'Configuration'.");
    }
  }
}