View source
<?php
namespace Drupal\Tests\jsonapi\Functional;
use Drupal\Core\Url;
use Drupal\user\Entity\Role;
class RoleTest extends ResourceTestBase {
public static $modules = [
'user',
];
protected $defaultTheme = 'stark';
protected static $entityTypeId = 'user_role';
protected static $resourceTypeName = 'user_role--user_role';
protected $entity;
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer permissions',
]);
}
protected function createEntity() {
$role = Role::create([
'id' => 'llama',
'name' => $this
->randomString(),
]);
$role
->save();
return $role;
}
protected function getExpectedDocument() {
$self_url = Url::fromUri('base:/jsonapi/user_role/user_role/' . $this->entity
->uuid())
->setAbsolute()
->toString(TRUE)
->getGeneratedUrl();
return [
'jsonapi' => [
'meta' => [
'links' => [
'self' => [
'href' => 'http://jsonapi.org/format/1.0/',
],
],
],
'version' => '1.0',
],
'links' => [
'self' => [
'href' => $self_url,
],
],
'data' => [
'id' => $this->entity
->uuid(),
'type' => 'user_role--user_role',
'links' => [
'self' => [
'href' => $self_url,
],
],
'attributes' => [
'weight' => 2,
'langcode' => 'en',
'status' => TRUE,
'dependencies' => [],
'label' => NULL,
'is_admin' => NULL,
'permissions' => [],
'drupal_internal__id' => 'llama',
],
],
];
}
protected function getPostDocument() {
}
}