You are here

public function ActionUnitTest::testDependencies in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Action/ActionUnitTest.php \Drupal\system\Tests\Action\ActionUnitTest::testDependencies()

Tests the dependency calculation of actions.

File

core/modules/system/src/Tests/Action/ActionUnitTest.php, line 81
Contains \Drupal\system\Tests\Action\ActionUnitTest.

Class

ActionUnitTest
Tests action plugins.

Namespace

Drupal\system\Tests\Action

Code

public function testDependencies() {

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