class ActionResourceTestBase

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/src/Functional/Rest/ActionResourceTestBase.php \Drupal\Tests\system\Functional\Rest\ActionResourceTestBase
  2. 10 core/modules/system/tests/src/Functional/Rest/ActionResourceTestBase.php \Drupal\Tests\system\Functional\Rest\ActionResourceTestBase
  3. 8.9.x core/modules/rest/tests/src/Functional/EntityResource/Action/ActionResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\Action\ActionResourceTestBase
  4. 8.9.x core/modules/system/tests/src/Functional/Rest/ActionResourceTestBase.php \Drupal\Tests\system\Functional\Rest\ActionResourceTestBase

Hierarchy

Expanded class hierarchy of ActionResourceTestBase

3 files declare their use of ActionResourceTestBase
ActionHalJsonAnonTest.php in core/modules/hal/tests/src/Functional/system/ActionHalJsonAnonTest.php
ActionHalJsonBasicAuthTest.php in core/modules/hal/tests/src/Functional/system/ActionHalJsonBasicAuthTest.php
ActionHalJsonCookieTest.php in core/modules/hal/tests/src/Functional/system/ActionHalJsonCookieTest.php

File

core/modules/system/tests/src/Functional/Rest/ActionResourceTestBase.php, line 9

Namespace

Drupal\Tests\system\Functional\Rest
View source
abstract class ActionResourceTestBase extends ConfigEntityResourceTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'action',
    'user',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected static $entityTypeId = 'action';
  
  /**
   * @var \Drupal\system\ActionConfigEntityInterface
   */
  protected $entity;
  
  /**
   * {@inheritdoc}
   */
  protected function setUpAuthorization($method) {
    $this->grantPermissionsToTestedRole([
      'administer actions',
    ]);
  }
  
  /**
   * {@inheritdoc}
   */
  protected function createEntity() {
    $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();
    return $action;
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getExpectedNormalizedEntity() {
    return [
      'configuration' => [
        'rid' => 'anonymous',
      ],
      'dependencies' => [
        'config' => [
          'user.role.anonymous',
        ],
        'module' => [
          'user',
        ],
      ],
      'id' => 'user_add_role_action.anonymous',
      'label' => 'Add the anonymous role to the selected users',
      'langcode' => 'en',
      'plugin' => 'user_add_role_action',
      'status' => TRUE,
      'type' => 'user',
      'uuid' => $this->entity
        ->uuid(),
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getNormalizedPostEntity() {
    // @todo Update in https://www.drupal.org/node/2300677.
    return [];
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.