function StateFileExistsTest::testMigrationState

Same name and namespace in other branches
  1. 9 core/modules/migrate_drupal/tests/src/Kernel/StateFileExistsTest.php \Drupal\Tests\migrate_drupal\Kernel\StateFileExistsTest::testMigrationState()
  2. 11.x core/modules/migrate_drupal/tests/src/Kernel/StateFileExistsTest.php \Drupal\Tests\migrate_drupal\Kernel\StateFileExistsTest::testMigrationState()

Tests that the migrate_drupal.yml files exist as needed.

File

core/modules/migrate_drupal/tests/src/Kernel/StateFileExistsTest.php, line 88

Class

StateFileExistsTest
Tests that core modules have a migrate_drupal.yml file as needed.

Namespace

Drupal\Tests\migrate_drupal\Kernel

Code

public function testMigrationState() : void {
  // Install all available modules.
  $module_handler = $this->container
    ->get('module_handler');
  $all_modules = $this->coreModuleListDataProvider();
  $modules_enabled = $module_handler->getModuleList();
  $modules_to_enable = array_keys(array_diff_key($all_modules, $modules_enabled));
  $this->enableModules($modules_to_enable);
  // Modules with a migrate_drupal.yml file.
  $has_state_file = (new YamlDiscovery('migrate_drupal', array_map(function ($value) {
    return $value . '/migrations/state';
  }, $module_handler->getModuleDirectories())))
    ->findAll();
  foreach ($this->stateFileRequired as $module) {
    $this->assertArrayHasKey($module, $has_state_file, sprintf("Module '%s' should have a migrate_drupal.yml file", $module));
  }
  $this->assertSameSize($this->stateFileRequired, $has_state_file);
}

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