You are here

public function ConfigImporterTest::testInstallProfile in Drupal 10

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

Tests install profile validation during configuration import.

See also

\Drupal\Core\EventSubscriber\ConfigImportSubscriber

File

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

Class

ConfigImporterTest
Tests importing configuration from files into active configuration.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testInstallProfile() {
  $sync = $this->container
    ->get('config.storage.sync');
  $extensions = $sync
    ->read('core.extension');

  // Add an install profile.
  $extensions['module']['standard'] = 0;
  $sync
    ->write('core.extension', $extensions);
  $config_importer = $this
    ->configImporter();
  try {
    $config_importer
      ->import();
    $this
      ->fail('ConfigImporterException not thrown; an invalid import was not stopped due to missing dependencies.');
  } catch (ConfigImporterException $e) {
    $expected = static::FAIL_MESSAGE . PHP_EOL . 'Unable to install the <em class="placeholder">standard</em> module since it does not exist.';
    $this
      ->assertEquals($expected, $e
      ->getMessage(), 'There were errors validating the config synchronization.');
    $error_log = $config_importer
      ->getErrors();

    // Install profiles should not even be scanned at this point.
    $this
      ->assertEquals([
      'Unable to install the <em class="placeholder">standard</em> module since it does not exist.',
    ], $error_log);
  }
}