public function ConfigActionsTransformTest::testReplace in Config Actions 8
@covers ::replace
File
- tests/
src/ Unit/ ConfigActionsTransformTest.php, line 20
Class
- ConfigActionsTransformTest
- test the ConfigActionsTransform class
Namespace
Drupal\Tests\config_actions\UnitCode
public function testReplace() {
$source = Yaml::decode(file_get_contents(dirname(__FILE__) . "/node.type.page.yml"));
$replace = [
"needs_review" => "approver",
"workbench" => "workflow",
"@bundle@" => "page",
];
$output = ConfigActionsTransform::replace($source, $replace);
$new_source = $source;
$new_source['dependencies']['module'][1] = 'workflow_moderation';
// 'workbench' only replaced with 'workflow' in values
$new_source['third_party_settings']['workbench_moderation']['allowed_moderation_states'][2] = 'approver';
$new_source['type'] = 'page';
self::assertEquals($new_source, $output);
$items = [
"workbench_moderation",
"state_needs_review",
"unaltered",
];
$output = ConfigActionsTransform::replace($items, $replace);
self::assertEquals([
"workflow_moderation",
"state_approver",
"unaltered",
], $output);
// Now test replacing 'workbench' with 'workflow' in keys.
$replace_keys = [
'workbench' => 'workflow',
];
$output = ConfigActionsTransform::replace($source, $replace, $replace_keys);
$value = $new_source['third_party_settings']['workbench_moderation'];
$new_source['third_party_settings']['workflow_moderation'] = $value;
unset($new_source['third_party_settings']['workbench_moderation']);
self::assertEquals($new_source, $output);
}