3 namespace Drupal\Tests\field\Kernel;
5 use Drupal\field\Entity\FieldConfig;
8 * Update field storage and fields during config change method invocation.
12 class FieldImportChangeTest extends FieldKernelTestBase {
17 * The default configuration provided by field_test_config is imported by
18 * \Drupal\Tests\field\Kernel\FieldKernelTestBase::setUp() when it installs
19 * field configuration.
23 public static $modules = ['field_test_config'];
26 * Tests importing an updated field.
28 public function testImportChange() {
29 $this->installConfig(['field_test_config']);
30 $field_storage_id = 'field_test_import';
31 $field_id = "entity_test.entity_test.$field_storage_id";
32 $field_config_name = "field.field.$field_id";
34 $active = $this->container->get('config.storage');
35 $sync = $this->container->get('config.storage.sync');
36 $this->copyConfig($active, $sync);
38 // Save as files in the sync directory.
39 $field = $active->read($field_config_name);
40 $new_label = 'Test update import field';
41 $field['label'] = $new_label;
42 $sync->write($field_config_name, $field);
44 // Import the content of the sync directory.
45 $this->configImporter()->import();
47 // Check that the updated config was correctly imported.
48 $field = FieldConfig::load($field_id);
49 $this->assertEqual($field->getLabel(), $new_label, 'field label updated');