You are here

function ConfigActionsPluginTest::testPipeline in Config Actions 8

Test the pipeline for saving config

File

tests/src/Kernel/ConfigActionsPluginTest.php, line 668

Class

ConfigActionsPluginTest
test the ConfigActions plugins

Namespace

Drupal\Tests\config_actions\Kernel

Code

function testPipeline() {
  $source = 'user.role.myrole';
  $action = [
    // Test global options passed to actions.
    'source' => $source,
    'path' => [
      'permissions',
    ],
    'actions' => [
      'add-permission-1' => [
        'plugin' => 'add',
        'value' => 'permission1',
      ],
      // Doing a Prune here would fail without a pipeline since the
      // config couldn't be saved without the permissions config key.
      'delete-permissions' => [
        'plugin' => 'delete',
        'prune' => TRUE,
      ],
      'add-permission-2' => [
        'plugin' => 'add',
        'value' => 'permission2',
      ],
    ],
  ];
  $this->configActions
    ->processAction($action);
  $new_config = $this
    ->getConfig($source);
  self::assertEquals([
    'permission2',
  ], $new_config['permissions']);
}