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. 10 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 354

Class

ConfigImportUITest
Tests the user interface for importing configuration.

Namespace

Drupal\Tests\config\Functional

Code

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->assertNoText(t('There are no configuration changes to import.'));
    $this->drupalPostForm(NULL, [], t('Import all'));
    // Verify that the validation messages appear.
    $this->assertText('The configuration cannot be imported because it failed validation for the following reasons:');
    $this->assertText('Config import validate error 1.');
    $this->assertText('Config import validate error 2.');
    // Verify site name has not changed.
    $this->assertNotEqual($new_site_name, $this->config('system.site')
        ->get('name'));
}

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