function StateFileExists::testMigrationState

Tests that the migrate_drupal.yml files exist as needed.

File

core/modules/migrate_drupal/tests/src/Kernel/StateFileExists.php, line 90

Class

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

Namespace

Drupal\Tests\migrate_drupal\Kernel

Code

public function testMigrationState() {
    // 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->assertEquals(count($this->stateFileRequired), count($has_state_file));
}

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