ActionResourceTestBase.php

Same filename in this branch
  1. 11.x core/modules/system/tests/src/Functional/Rest/ActionResourceTestBase.php
Same filename in other branches
  1. 9 core/modules/system/tests/src/Functional/Rest/ActionResourceTestBase.php
  2. 8.9.x core/modules/rest/tests/src/Functional/EntityResource/Action/ActionResourceTestBase.php
  3. 8.9.x core/modules/system/tests/src/Functional/Rest/ActionResourceTestBase.php
  4. 10 core/modules/action/tests/src/Functional/Rest/ActionResourceTestBase.php
  5. 10 core/modules/system/tests/src/Functional/Rest/ActionResourceTestBase.php

Namespace

Drupal\Tests\action\Functional\Rest

File

core/modules/action/tests/src/Functional/Rest/ActionResourceTestBase.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\action\Functional\Rest;

use Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase;
use Drupal\system\Entity\Action;
use Drupal\user\RoleInterface;
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 [];
    }

}

Classes

Title Deprecated Summary
ActionResourceTestBase

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