You are here

public function ConfigImporterTest::testInstallProfile in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config/src/Tests/ConfigImporterTest.php \Drupal\config\Tests\ConfigImporterTest::testInstallProfile()

Tests install profile validation during configuration import.

See also

\Drupal\Core\EventSubscriber\ConfigImportSubscriber

File

core/modules/config/src/Tests/ConfigImporterTest.php, line 656
Contains \Drupal\config\Tests\ConfigImporterTest.

Class

ConfigImporterTest
Tests importing configuration from files into active configuration.

Namespace

Drupal\config\Tests

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);
  try {
    $this->configImporter
      ->reset()
      ->import();
    $this
      ->fail('ConfigImporterException not thrown; an invalid import was not stopped due to missing dependencies.');
  } catch (ConfigImporterException $e) {
    $this
      ->assertEqual($e
      ->getMessage(), 'There were errors validating the config synchronization.');
    $error_log = $this->configImporter
      ->getErrors();

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