function ConfigImportUITest::testImportValidation

Same name in other branches
  1. 9 core/modules/config/tests/src/Functional/ConfigImportUITest.php \Drupal\Tests\config\Functional\ConfigImportUITest::testImportValidation()
  2. 8.9.x core/modules/config/tests/src/Functional/ConfigImportUITest.php \Drupal\Tests\config\Functional\ConfigImportUITest::testImportValidation()
  3. 11.x 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 361

Class

ConfigImportUITest
Tests the user interface for importing configuration.

Namespace

Drupal\Tests\config\Functional

Code

public function testImportValidation() : void {
    // 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);
}

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