function DestinationCategoryTest::assertCategories

Same name in other branches
  1. 8.9.x core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/DestinationCategoryTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\DestinationCategoryTest::assertCategories()
  2. 10 core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/DestinationCategoryTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\DestinationCategoryTest::assertCategories()
  3. 11.x 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.

@internal

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 73

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(array $migrations) : void {
    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'.");
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.