You are here

abstract class RoleResourceTestBase in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/user/tests/src/Functional/Rest/RoleResourceTestBase.php \Drupal\Tests\user\Functional\Rest\RoleResourceTestBase
  2. 9 core/modules/user/tests/src/Functional/Rest/RoleResourceTestBase.php \Drupal\Tests\user\Functional\Rest\RoleResourceTestBase

Hierarchy

Expanded class hierarchy of RoleResourceTestBase

File

core/modules/user/tests/src/Functional/Rest/RoleResourceTestBase.php, line 8

Namespace

Drupal\Tests\user\Functional\Rest
View source
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' => NULL,
      'permissions' => [],
    ];
  }

  /**
   * {@inheritdoc}
   */
  protected function getNormalizedPostEntity() {

    // @todo Update in https://www.drupal.org/node/2300677.
    return [];
  }

}

Members