You are here

public function ConfigImporterTest::testRequiredModuleValidation in Drupal 10

Tests uninstall validators being called during synchronization.

See also

\Drupal\Core\EventSubscriber\ConfigImportSubscriber

File

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

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]);
  }
}