You are here

public function ConfigImportUITest::testImportErrorLog in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/config/tests/src/Functional/ConfigImportUITest.php \Drupal\Tests\config\Functional\ConfigImportUITest::testImportErrorLog()
  2. 10 core/modules/config/tests/src/Functional/ConfigImportUITest.php \Drupal\Tests\config\Functional\ConfigImportUITest::testImportErrorLog()

Tests an import that results in an error.

File

core/modules/config/tests/src/Functional/ConfigImportUITest.php, line 402

Class

ConfigImportUITest
Tests the user interface for importing configuration.

Namespace

Drupal\Tests\config\Functional

Code

public 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 = [
    'uuid' => $uuid
      ->generate(),
    'langcode' => 'en',
    'status' => TRUE,
    'dependencies' => [],
    'id' => 'primary',
    'label' => 'Primary',
    'weight' => 0,
    'style' => NULL,
    'size' => NULL,
    'size_value' => NULL,
    'protected_property' => NULL,
  ];
  $sync
    ->write($name_primary, $values_primary);
  $values_secondary = [
    'uuid' => $uuid
      ->generate(),
    'langcode' => 'en',
    'status' => TRUE,
    // Add a dependency on primary, to ensure that is synced first.
    'dependencies' => [
      'config' => [
        $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, [], t('Import all'));
  $this
    ->assertText(new FormattableMarkup('Deleted and replaced configuration entity "@name"', [
    '@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.'));
}