You are here

public function ConfigIgnoreTest::testSyncTableUpdate in Config Ignore 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/ConfigIgnoreTest.php \Drupal\Tests\config_ignore\Functional\ConfigIgnoreTest::testSyncTableUpdate()

Verify that the Sync. table gets update with appropriate ignore actions.

File

tests/src/Functional/ConfigIgnoreTest.php, line 24

Class

ConfigIgnoreTest
Test functionality of config_ignore module.

Namespace

Drupal\Tests\config_ignore\Functional

Code

public function testSyncTableUpdate() {
  $this
    ->config('system.site')
    ->set('name', 'Test import')
    ->save();
  $this
    ->config('system.date')
    ->set('first_day', '0')
    ->save();
  $this
    ->config('config_ignore.settings')
    ->set('ignored_config_entities', [
    'system.site',
  ])
    ->save();
  $this
    ->doExport();

  // Login with a user that has permission to sync. config.
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'synchronize configuration',
  ]));

  // Change the site name, which is supposed to look as an ignored change
  // in on the sync. page.
  $this
    ->config('system.site')
    ->set('name', 'Test import with changed title')
    ->save();
  $this
    ->config('system.date')
    ->set('first_day', '1')
    ->save();

  // Validate that the sync. table informs the user that the config will be
  // ignored.
  $this
    ->drupalGet('admin/config/development/configuration');
  $this
    ->assertSession()
    ->linkExists('Config Ignore Settings');

  /** @var \Behat\Mink\Element\NodeElement[] $table_content */
  $table_content = $this
    ->xpath('//table[@id="edit-ignored"]//td');
  $table_values = [];
  foreach ($table_content as $item) {
    $table_values[] = $item
      ->getHtml();
  }
  $this
    ->assertTrue(in_array('system.site', $table_values));
  $this
    ->assertFalse(in_array('system.date', $table_values));
}