You are here

function ConfigImportUITest::testImportErrorLog in Zircon Profile 8

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

Tests an import that results in an error.

File

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

Class

ConfigImportUITest
Tests the user interface for importing/exporting configuration.

Namespace

Drupal\config\Tests

Code

function testImportErrorLog() {
  $name_primary = 'config_test.dynamic.primary';
  $name_secondary = 'config_test.dynamic.secondary';
  $sync = $this->container
    ->get('config.storage.sync');
  $uuid = $this->container
    ->get('uuid');
  $values_primary = array(
    'uuid' => $uuid
      ->generate(),
    'langcode' => 'en',
    'status' => TRUE,
    'dependencies' => array(),
    'id' => 'primary',
    'label' => 'Primary',
    'weight' => 0,
    'style' => NULL,
    'size' => NULL,
    'size_value' => NULL,
    'protected_property' => NULL,
  );
  $sync
    ->write($name_primary, $values_primary);
  $values_secondary = array(
    'uuid' => $uuid
      ->generate(),
    'langcode' => 'en',
    'status' => TRUE,
    // Add a dependency on primary, to ensure that is synced first.
    'dependencies' => array(
      'config' => array(
        $name_primary,
      ),
    ),
    'id' => 'secondary',
    'label' => 'Secondary Sync',
    'weight' => 0,
    'style' => NULL,
    'size' => NULL,
    'size_value' => NULL,
    'protected_property' => NULL,
  );
  $sync
    ->write($name_secondary, $values_secondary);

  // Verify that there are configuration differences to import.
  $this
    ->drupalGet('admin/config/development/configuration');
  $this
    ->assertNoText(t('There are no configuration changes to import.'));

  // Attempt to import configuration and verify that an error message appears.
  $this
    ->drupalPostForm(NULL, array(), t('Import all'));
  $this
    ->assertText(SafeMarkup::format('Deleted and replaced configuration entity "@name"', array(
    '@name' => $name_secondary,
  )));
  $this
    ->assertText(t('The configuration was imported with errors.'));
  $this
    ->assertNoText(t('The configuration was imported successfully.'));
  $this
    ->assertText(t('There are no configuration changes to import.'));
}