protected function ConfigEntityImportTest::checkSinglePluginConfigSync in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Kernel/Entity/ConfigEntityImportTest.php \Drupal\Tests\system\Kernel\Entity\ConfigEntityImportTest::checkSinglePluginConfigSync()
Tests that a single set of plugin config stays in sync.
Parameters
\Drupal\Core\Entity\EntityWithPluginCollectionInterface $entity: The entity.
string $config_key: Where the plugin config is stored.
string $setting_key: The setting within the plugin config to change.
mixed $expected: The expected default value of the plugin config setting.
3 calls to ConfigEntityImportTest::checkSinglePluginConfigSync()
- ConfigEntityImportTest::doActionUpdate in core/
modules/ system/ tests/ src/ Kernel/ Entity/ ConfigEntityImportTest.php - Tests updating an action during import.
- ConfigEntityImportTest::doBlockUpdate in core/
modules/ system/ tests/ src/ Kernel/ Entity/ ConfigEntityImportTest.php - Tests updating a block during import.
- ConfigEntityImportTest::doSearchPageUpdate in core/
modules/ system/ tests/ src/ Kernel/ Entity/ ConfigEntityImportTest.php - Tests updating a search page during import.
File
- core/
modules/ system/ tests/ src/ Kernel/ Entity/ ConfigEntityImportTest.php, line 226
Class
- ConfigEntityImportTest
- Tests ConfigEntity importing.
Namespace
Drupal\Tests\system\Kernel\EntityCode
protected function checkSinglePluginConfigSync(EntityWithPluginCollectionInterface $entity, $config_key, $setting_key, $expected) {
$plugin_collection = $entity
->getPluginCollections()[$config_key];
$settings = $entity
->get($config_key);
// Ensure the default config exists.
$this
->assertSame($expected, $settings[$setting_key]);
// Change the plugin config by setting it on the entity.
$settings[$setting_key] = $this
->randomString();
$entity
->set($config_key, $settings);
$entity
->save();
$this
->assertSame($settings, $entity
->get($config_key));
$this
->assertSame($settings, $plugin_collection
->getConfiguration());
// Change the plugin config by setting it on the plugin.
$settings[$setting_key] = $this
->randomString();
$plugin_collection
->setConfiguration($settings);
$entity
->save();
$this
->assertSame($settings, $entity
->get($config_key));
$this
->assertSame($settings, $plugin_collection
->getConfiguration());
}