class FieldImportChangeTest
Same name and namespace in other branches
- 11.x core/modules/field/tests/src/Kernel/FieldImportChangeTest.php \Drupal\Tests\field\Kernel\FieldImportChangeTest
- 10 core/modules/field/tests/src/Kernel/FieldImportChangeTest.php \Drupal\Tests\field\Kernel\FieldImportChangeTest
- 8.9.x core/modules/field/tests/src/Kernel/FieldImportChangeTest.php \Drupal\Tests\field\Kernel\FieldImportChangeTest
Update field storage and fields during config change method invocation.
@group field
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\field\Kernel\FieldKernelTestBase extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\field\Kernel\FieldImportChangeTest extends \Drupal\Tests\field\Kernel\FieldKernelTestBase
- class \Drupal\Tests\field\Kernel\FieldKernelTestBase extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of FieldImportChangeTest
File
-
core/
modules/ field/ tests/ src/ Kernel/ FieldImportChangeTest.php, line 12
Namespace
Drupal\Tests\field\KernelView source
class FieldImportChangeTest extends FieldKernelTestBase {
/**
* Modules to enable.
*
* The default configuration provided by field_test_config is imported by
* \Drupal\Tests\field\Kernel\FieldKernelTestBase::setUp() when it installs
* field configuration.
*
* @var array
*/
protected static $modules = [
'field_test_config',
];
/**
* Tests importing an updated field.
*/
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);
// Save as files in the sync directory.
$field = $active->read($field_config_name);
$new_label = 'Test update import field';
$field['label'] = $new_label;
$sync->write($field_config_name, $field);
// Import the content of the sync directory.
$this->configImporter()
->import();
// Check that the updated config was correctly imported.
$field = FieldConfig::load($field_id);
$this->assertEquals($new_label, $field->getLabel(), 'field label updated');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.