You are here

public function ConfigActionsPluginTest::testNested in Config Actions 8

Test nested actions.

File

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

Class

ConfigActionsPluginTest
test the ConfigActions plugins

Namespace

Drupal\Tests\config_actions\Kernel

Code

public function testNested() {
  $source = 'core.date_format.@format@';
  $value = 'My new label';
  $action = [
    // Test global options passed to actions.
    'source' => $source,
    'path' => [
      'label',
    ],
    'replace_in' => [
      'source',
    ],
    'actions' => [
      'long-action' => [
        'replace' => [
          '@format@' => 'long',
        ],
        'actions' => [
          'change-action' => [
            'plugin' => 'change',
            'value' => $value,
          ],
          'change-status' => [
            'plugin' => 'change',
            // Test overriding path option for specific action.
            'path' => [
              'locked',
            ],
            'value' => true,
          ],
        ],
      ],
      'short-action' => [
        'plugin' => 'change',
        'value' => $value,
        // Test a different format variable
        'replace' => [
          '@format@' => 'short',
        ],
      ],
    ],
  ];
  $orig_config_long = $this
    ->getConfig('core.date_format.long');
  $orig_config_short = $this
    ->getConfig('core.date_format.short');
  $this->configActions
    ->processAction($action);
  $new_config_long = $this
    ->getConfig('core.date_format.long');
  $new_config_short = $this
    ->getConfig('core.date_format.short');
  $orig_config_long['label'] = $value;
  $orig_config_long['locked'] = true;
  $orig_config_short['label'] = $value;
  self::assertEquals($orig_config_long, $new_config_long);
  self::assertEquals($orig_config_short, $new_config_short);
}