You are here

public function ConfigImportUITest::testImportValidation in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/config/src/Tests/ConfigImportUITest.php \Drupal\config\Tests\ConfigImportUITest::testImportValidation()

Tests that multiple validation errors are listed on the page.

File

core/modules/config/src/Tests/ConfigImportUITest.php, line 344
Contains \Drupal\config\Tests\ConfigImportUITest.

Class

ConfigImportUITest
Tests the user interface for importing/exporting configuration.

Namespace

Drupal\config\Tests

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, array(), 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'));
}