FieldImportChangeTest.php in Drupal 9
File
core/modules/field/tests/src/Kernel/FieldImportChangeTest.php
View source
<?php
namespace Drupal\Tests\field\Kernel;
use Drupal\field\Entity\FieldConfig;
class FieldImportChangeTest extends FieldKernelTestBase {
protected static $modules = [
'field_test_config',
];
public function testImportChange() {
$this
->installConfig([
'field_test_config',
]);
$field_storage_id = 'field_test_import';
$field_id = "entity_test.entity_test.{$field_storage_id}";
$field_config_name = "field.field.{$field_id}";
$active = $this->container
->get('config.storage');
$sync = $this->container
->get('config.storage.sync');
$this
->copyConfig($active, $sync);
$field = $active
->read($field_config_name);
$new_label = 'Test update import field';
$field['label'] = $new_label;
$sync
->write($field_config_name, $field);
$this
->configImporter()
->import();
$field = FieldConfig::load($field_id);
$this
->assertEquals($new_label, $field
->getLabel(), 'field label updated');
}
}