You are here

public function ConfigIgnoreTest::testConfigNotIgnored in Config Ignore Keys 8

Verifies items import correctly.

File

tests/src/Kernel/ConfigIgnoreTest.php, line 128

Class

ConfigIgnoreTest
Class ConfigIgnoreTest.

Namespace

Drupal\Tests\config_ignore_keys\Kernel

Code

public function testConfigNotIgnored() {
  $content_type = NodeType::load(static::NODE_TYPE_NAME);

  // Change the body field name. This should not be ignored by the import.
  $field = FieldConfig::loadByName('node', $content_type
    ->id(), 'body');
  $field
    ->set('label', 'New label');
  $field
    ->save();
  $this->configImporter
    ->reset();
  $updates = $this->configImporter
    ->getUnprocessedConfiguration('update');
  self::assertEquals(1, count($updates), 'There is 1 configuration item to update.');

  // Import the configuration containing the old content type node.
  $this->configImporter
    ->reset()
    ->import();

  // Check that the body field label was changed, as it should not be ignored.
  $field = FieldConfig::loadByName('node', $content_type
    ->id(), 'body');
  self::assertEquals($field
    ->get('label'), 'Body');
}