function ConfigImporterTest::testInstallProfile

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testInstallProfile()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testInstallProfile()
  3. 10 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 729

Class

ConfigImporterTest
Tests importing configuration from files into active configuration.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testInstallProfile() : void {
    $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 standard module since it does not exist.',
        ], $error_log);
    }
}

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