Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / field / tests / src / Kernel / FieldImportChangeTest.php
1 <?php
2
3 namespace Drupal\Tests\field\Kernel;
4
5 use Drupal\field\Entity\FieldConfig;
6
7 /**
8  * Update field storage and fields during config change method invocation.
9  *
10  * @group field
11  */
12 class FieldImportChangeTest extends FieldKernelTestBase {
13
14   /**
15    * Modules to enable.
16    *
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.
20    *
21    * @var array
22    */
23   public static $modules = ['field_test_config'];
24
25   /**
26    * Tests importing an updated field.
27    */
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";
33
34     $active = $this->container->get('config.storage');
35     $sync = $this->container->get('config.storage.sync');
36     $this->copyConfig($active, $sync);
37
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);
43
44     // Import the content of the sync directory.
45     $this->configImporter()->import();
46
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');
50   }
51
52 }