public function ConfigImportUITest::testImportValidation in Drupal 10
Same name and namespace in other branches
- 8 core/modules/config/tests/src/Functional/ConfigImportUITest.php \Drupal\Tests\config\Functional\ConfigImportUITest::testImportValidation()
- 9 core/modules/config/tests/src/Functional/ConfigImportUITest.php \Drupal\Tests\config\Functional\ConfigImportUITest::testImportValidation()
Tests that multiple validation errors are listed on the page.
File
- core/
modules/ config/ tests/ src/ Functional/ ConfigImportUITest.php, line 358
Class
- ConfigImportUITest
- Tests the user interface for importing configuration.
Namespace
Drupal\Tests\config\FunctionalCode
public function testImportValidation() {
// Set state value so that
// \Drupal\config_import_test\EventSubscriber::onConfigImportValidate() logs
// validation errors.
\Drupal::state()
->set('config_import_test.config_import_validate_fail', TRUE);
// Ensure there is something to import.
$new_site_name = 'Config import test ' . $this
->randomString();
$this
->prepareSiteNameUpdate($new_site_name);
$this
->drupalGet('admin/config/development/configuration');
$this
->assertSession()
->pageTextNotContains('The staged configuration is identical to the active configuration.');
$this
->submitForm([], 'Import all');
// Verify that the validation messages appear.
$this
->assertSession()
->pageTextContains('The configuration cannot be imported because it failed validation for the following reasons:');
$this
->assertSession()
->pageTextContains('Config import validate error 1.');
$this
->assertSession()
->pageTextContains('Config import validate error 2.');
// Verify site name has not changed.
$this
->assertNotEquals($this
->config('system.site')
->get('name'), $new_site_name);
}