public function ConfigActionsPluginTest::testChange in Config Actions 8
@covers \Drupal\config_actions\Plugin\ConfigActions\ConfigActionsChange
File
- tests/
src/ Kernel/ ConfigActionsPluginTest.php, line 243
Class
- ConfigActionsPluginTest
- test the ConfigActions plugins
Namespace
Drupal\Tests\config_actions\KernelCode
public function testChange() {
$source = 'core.date_format.long';
$value = 'My new label';
$action = [
'plugin' => 'change',
'source' => $source,
'path' => [
'label',
],
'value' => $value,
];
$orig_config = $this
->getConfig($source);
$this->configActions
->processAction($action);
$new_config = $this
->getConfig($source);
$orig_config['label'] = $value;
self::assertEquals($orig_config, $new_config);
$value = 'Another new label';
$action = [
'plugin' => 'change',
'source' => $source,
'value' => [
'label' => $value,
],
];
$orig_config = $this
->getConfig($source);
$this->configActions
->processAction($action);
$new_config = $this
->getConfig($source);
$orig_config['label'] = $value;
self::assertEquals($orig_config, $new_config);
$new_value = 'New Value';
$action = [
'plugin' => 'change',
'source' => $source,
'path' => [
'label',
],
'value' => $new_value,
'current_value' => $value,
];
$orig_config = $this
->getConfig($source);
$this->configActions
->processAction($action);
$new_config = $this
->getConfig($source);
$orig_config['label'] = $new_value;
self::assertEquals($orig_config, $new_config);
$action = [
'plugin' => 'change',
'source' => $source,
'path' => [
'label',
],
'value' => $value,
'current_value' => 'NONE',
];
$this
->expectException(\Exception::class);
$this
->expectExceptionMessage('Failed to validate path value for config action.');
$this->configActions
->processAction($action);
}