function ConfigImportUITest::testImportErrorLog

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

Class

ConfigImportUITest
Tests the user interface for importing configuration.

Namespace

Drupal\Tests\config\Functional

Code

public function testImportErrorLog() : void {
  $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->assertSession()
    ->pageTextNotContains('The staged configuration is identical to the active configuration.');
  // Attempt to import configuration and verify that an error message appears.
  $this->submitForm([], 'Import all');
  $this->assertSession()
    ->pageTextContains('Deleted and replaced configuration entity "' . $name_secondary . '"');
  $this->assertSession()
    ->pageTextContains('The configuration was imported with errors.');
  $this->assertSession()
    ->pageTextNotContains('The configuration was imported successfully.');
  $this->assertSession()
    ->pageTextContains('The staged configuration is identical to the active configuration.');
}

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