You are here

public function ConfigActionsTransformTest::testDelete in Config Actions 8

@covers ::delete

File

tests/src/Unit/ConfigActionsTransformTest.php, line 102

Class

ConfigActionsTransformTest
test the ConfigActionsTransform class

Namespace

Drupal\Tests\config_actions\Unit

Code

public function testDelete() {
  $source = Yaml::decode(file_get_contents(dirname(__FILE__) . "/node.type.page.yml"));
  $output = ConfigActionsTransform::delete($source, [
    "dependencies",
    "module",
  ], true);
  unset($source['dependencies']);
  self::assertEquals($source, $output);
  $output = ConfigActionsTransform::delete($source, [
    'description',
  ], true);
  $new_source = $source;
  unset($new_source['description']);
  self::assertEquals($new_source, $output);

  // Test clearing string value without pruning.
  $output = ConfigActionsTransform::delete($source, [
    'description',
  ]);
  $new_source = $source;
  $new_source['description'] = '';
  self::assertEquals($new_source, $output);
}