You are here

public function ConfigImporterTest::testMissingCoreExtension in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testMissingCoreExtension()

Tests missing core.extension during configuration import.

See also

\Drupal\Core\EventSubscriber\ConfigImportSubscriber

File

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

Class

ConfigImporterTest
Tests importing configuration from files into active configuration.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testMissingCoreExtension() {
  $sync = $this->container
    ->get('config.storage.sync');
  $sync
    ->delete('core.extension');
  try {
    $this->configImporter
      ->reset()
      ->import();
    $this
      ->fail('ConfigImporterException not thrown, invalid import was not stopped due to missing dependencies.');
  } catch (ConfigImporterException $e) {
    $expected = static::FAIL_MESSAGE . PHP_EOL . 'The core.extension configuration does not exist.';
    $this
      ->assertEquals($expected, $e
      ->getMessage());
    $error_log = $this->configImporter
      ->getErrors();
    $this
      ->assertEquals([
      'The core.extension configuration does not exist.',
    ], $error_log);
  }
}