comparison core/modules/jsonapi/tests/src/Functional/RoleTest.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
1 <?php
2
3 namespace Drupal\Tests\jsonapi\Functional;
4
5 use Drupal\Core\Url;
6 use Drupal\user\Entity\Role;
7
8 /**
9 * JSON:API integration test for the "Role" config entity type.
10 *
11 * @group jsonapi
12 */
13 class RoleTest extends ResourceTestBase {
14
15
16 /**
17 * {@inheritdoc}
18 */
19 public static $modules = ['user'];
20
21 /**
22 * {@inheritdoc}
23 */
24 protected static $entityTypeId = 'user_role';
25
26 /**
27 * {@inheritdoc}
28 */
29 protected static $resourceTypeName = 'user_role--user_role';
30
31 /**
32 * {@inheritdoc}
33 *
34 * @var \Drupal\user\RoleInterface
35 */
36 protected $entity;
37
38 /**
39 * {@inheritdoc}
40 */
41 protected function setUpAuthorization($method) {
42 $this->grantPermissionsToTestedRole(['administer permissions']);
43 }
44
45 /**
46 * {@inheritdoc}
47 */
48 protected function createEntity() {
49 $role = Role::create([
50 'id' => 'llama',
51 'name' => $this->randomString(),
52 ]);
53 $role->save();
54
55 return $role;
56 }
57
58 /**
59 * {@inheritdoc}
60 */
61 protected function getExpectedDocument() {
62 $self_url = Url::fromUri('base:/jsonapi/user_role/user_role/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl();
63 return [
64 'jsonapi' => [
65 'meta' => [
66 'links' => [
67 'self' => ['href' => 'http://jsonapi.org/format/1.0/'],
68 ],
69 ],
70 'version' => '1.0',
71 ],
72 'links' => [
73 'self' => ['href' => $self_url],
74 ],
75 'data' => [
76 'id' => $this->entity->uuid(),
77 'type' => 'user_role--user_role',
78 'links' => [
79 'self' => ['href' => $self_url],
80 ],
81 'attributes' => [
82 'weight' => 2,
83 'langcode' => 'en',
84 'status' => TRUE,
85 'dependencies' => [],
86 'label' => NULL,
87 'is_admin' => NULL,
88 'permissions' => [],
89 'drupal_internal__id' => 'llama',
90 ],
91 ],
92 ];
93 }
94
95 /**
96 * {@inheritdoc}
97 */
98 protected function getPostDocument() {
99 // @todo Update in https://www.drupal.org/node/2300677.
100 }
101
102 }