RoleResourceTestBase.php

Same filename in other branches
  1. 9 core/modules/user/tests/src/Functional/Rest/RoleResourceTestBase.php
  2. 8.9.x core/modules/rest/tests/src/Functional/EntityResource/Role/RoleResourceTestBase.php
  3. 8.9.x core/modules/user/tests/src/Functional/Rest/RoleResourceTestBase.php
  4. 10 core/modules/user/tests/src/Functional/Rest/RoleResourceTestBase.php

Namespace

Drupal\Tests\user\Functional\Rest

File

core/modules/user/tests/src/Functional/Rest/RoleResourceTestBase.php

View source
<?php

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

use Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase;
use Drupal\user\Entity\Role;
abstract class RoleResourceTestBase extends ConfigEntityResourceTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'user',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected static $entityTypeId = 'user_role';
    
    /**
     * @var \Drupal\user\RoleInterface
     */
    protected $entity;
    
    /**
     * {@inheritdoc}
     */
    protected function setUpAuthorization($method) {
        $this->grantPermissionsToTestedRole([
            'administer permissions',
        ]);
    }
    
    /**
     * {@inheritdoc}
     */
    protected function createEntity() {
        $role = Role::create([
            'id' => 'llama',
            'label' => 'Llama',
        ]);
        $role->save();
        return $role;
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getExpectedNormalizedEntity() {
        return [
            'uuid' => $this->entity
                ->uuid(),
            'weight' => 2,
            'langcode' => 'en',
            'status' => TRUE,
            'dependencies' => [],
            'id' => 'llama',
            'label' => 'Llama',
            'is_admin' => FALSE,
            'permissions' => [],
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getNormalizedPostEntity() {
        // @todo Update in https://www.drupal.org/node/2300677.
        return [];
    }

}

Classes

Title Deprecated Summary
RoleResourceTestBase

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