You are here

public function ActionTest::testDependencies in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Kernel/Action/ActionTest.php \Drupal\Tests\system\Kernel\Action\ActionTest::testDependencies()

Tests the dependency calculation of actions.

File

core/modules/system/tests/src/Kernel/Action/ActionTest.php, line 77

Class

ActionTest
Tests action plugins.

Namespace

Drupal\Tests\system\Kernel\Action

Code

public function testDependencies() {

  // Create a new action that depends on a user role.
  $action = Action::create([
    'id' => 'user_add_role_action.' . RoleInterface::ANONYMOUS_ID,
    'type' => 'user',
    'label' => t('Add the anonymous role to the selected users'),
    'configuration' => [
      'rid' => RoleInterface::ANONYMOUS_ID,
    ],
    'plugin' => 'user_add_role_action',
  ]);
  $action
    ->save();
  $expected = [
    'config' => [
      'user.role.' . RoleInterface::ANONYMOUS_ID,
    ],
    'module' => [
      'user',
    ],
  ];
  $this
    ->assertIdentical($expected, $action
    ->calculateDependencies()
    ->getDependencies());
}