function ConfigImporterTest::testRequiredModuleValidation

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testRequiredModuleValidation()
  2. 11.x core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testRequiredModuleValidation()

Tests uninstall validators being called during synchronization.

See also

\Drupal\Core\EventSubscriber\ConfigImportSubscriber

File

core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php, line 670

Class

ConfigImporterTest
Tests importing configuration from files into active configuration.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testRequiredModuleValidation() {
    $sync = $this->container
        ->get('config.storage.sync');
    $extensions = $sync->read('core.extension');
    unset($extensions['module']['system']);
    $sync->write('core.extension', $extensions);
    $config_importer = $this->configImporter();
    try {
        $config_importer->import();
        $this->fail('ConfigImporterException not thrown, invalid import was not stopped due to missing dependencies.');
    } catch (ConfigImporterException $e) {
        $this->assertStringContainsString('There were errors validating the config synchronization.', $e->getMessage());
        $error_log = $config_importer->getErrors();
        $this->assertEquals('Unable to uninstall the <em class="placeholder">System</em> module because: The System module is required.', $error_log[0]);
    }
}

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