public function ConfigImporterTest::testInstallProfileMisMatch in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testInstallProfileMisMatch()
- 9 core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testInstallProfileMisMatch()
Tests install profile validation during configuration import.
See also
\Drupal\Core\EventSubscriber\ConfigImportSubscriber
File
- core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigImporterTest.php, line 719
Class
- ConfigImporterTest
- Tests importing configuration from files into active configuration.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testInstallProfileMisMatch() {
$sync = $this->container
->get('config.storage.sync');
$extensions = $sync
->read('core.extension');
// Change the install profile.
$extensions['profile'] = 'this_will_not_work';
$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 . 'Cannot change the install profile from <em class="placeholder"></em> to <em class="placeholder">this_will_not_work</em> once Drupal is installed.';
$this
->assertEquals($expected, $e
->getMessage(), 'There were errors validating the config synchronization.');
$error_log = $config_importer
->getErrors();
// Install profiles can not be changed. Note that KernelTestBase currently
// does not use an install profile. This situation should be impossible
// to get in but site's can removed the install profile setting from
// settings.php so the test is valid.
$this
->assertEquals([
'Cannot change the install profile from <em class="placeholder"></em> to <em class="placeholder">this_will_not_work</em> once Drupal is installed.',
], $error_log);
}
}