You are here

public function CommerceMigrationLabelExistTest::testLabelExist in Commerce Migrate 3.0.x

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/CommerceMigrationLabelExistTest.php \Drupal\Tests\commerce_migrate\Kernel\CommerceMigrationLabelExistTest::testLabelExist()
  2. 3.1.x tests/src/Kernel/CommerceMigrationLabelExistTest.php \Drupal\Tests\commerce_migrate\Kernel\CommerceMigrationLabelExistTest::testLabelExist()

Tests that labels exist for all migrations.

File

tests/src/Kernel/CommerceMigrationLabelExistTest.php, line 266

Class

CommerceMigrationLabelExistTest
Tests that labels exist for all migrations.

Namespace

Drupal\Tests\commerce_migrate\Kernel

Code

public function testLabelExist() {

  // Install all available modules.
  $module_handler = $this->container
    ->get('module_handler');
  $modules = $this
    ->coreModuleListDataProvider();
  $modules_enabled = $module_handler
    ->getModuleList();
  $modules_to_enable = array_keys(array_diff_key($modules, $modules_enabled));
  $this
    ->enableModules($modules_to_enable);

  /** @var \Drupal\migrate\Plugin\MigrationPluginManager $plugin_manager */
  $plugin_manager = $this->container
    ->get('plugin.manager.migration');

  // Get all the commerce_migrate migrations.
  $migrations = [];
  foreach ($this->tags as $tag) {
    $migrations = array_merge($migrations, $plugin_manager
      ->createInstancesByTag($tag));
  }

  /** @var \Drupal\migrate\Plugin\Migration $migration */
  foreach ($migrations as $migration) {
    $migration_id = $migration
      ->getPluginId();
    $this
      ->assertNotEmpty($migration
      ->label(), 'Label not found for ' . $migration_id);
  }
}