comparison core/modules/jsonapi/tests/src/Functional/RestResourceConfigTest.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\rest\Entity\RestResourceConfig;
7
8 /**
9 * JSON:API integration test for the "RestResourceConfig" config entity type.
10 *
11 * @group jsonapi
12 */
13 class RestResourceConfigTest extends ResourceTestBase {
14
15 /**
16 * {@inheritdoc}
17 */
18 public static $modules = ['rest', 'dblog'];
19
20 /**
21 * {@inheritdoc}
22 */
23 protected static $entityTypeId = 'rest_resource_config';
24
25 /**
26 * {@inheritdoc}
27 */
28 protected static $resourceTypeName = 'rest_resource_config--rest_resource_config';
29
30 /**
31 * {@inheritdoc}
32 *
33 * @var \Drupal\rest\RestResourceConfigInterface
34 */
35 protected $entity;
36
37 /**
38 * {@inheritdoc}
39 */
40 protected function setUpAuthorization($method) {
41 $this->grantPermissionsToTestedRole(['administer rest resources']);
42 }
43
44 /**
45 * {@inheritdoc}
46 */
47 protected function createEntity() {
48 $rest_resource_config = RestResourceConfig::create([
49 'id' => 'llama',
50 'plugin_id' => 'dblog',
51 'granularity' => 'method',
52 'configuration' => [
53 'GET' => [
54 'supported_formats' => [
55 'json',
56 ],
57 'supported_auth' => [
58 'cookie',
59 ],
60 ],
61 ],
62 ]);
63 $rest_resource_config->save();
64
65 return $rest_resource_config;
66 }
67
68 /**
69 * {@inheritdoc}
70 */
71 protected function getExpectedDocument() {
72 $self_url = Url::fromUri('base:/jsonapi/rest_resource_config/rest_resource_config/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl();
73 return [
74 'jsonapi' => [
75 'meta' => [
76 'links' => [
77 'self' => ['href' => 'http://jsonapi.org/format/1.0/'],
78 ],
79 ],
80 'version' => '1.0',
81 ],
82 'links' => [
83 'self' => ['href' => $self_url],
84 ],
85 'data' => [
86 'id' => $this->entity->uuid(),
87 'type' => 'rest_resource_config--rest_resource_config',
88 'links' => [
89 'self' => ['href' => $self_url],
90 ],
91 'attributes' => [
92 'langcode' => 'en',
93 'status' => TRUE,
94 'dependencies' => [
95 'module' => [
96 'dblog',
97 'serialization',
98 'user',
99 ],
100 ],
101 'plugin_id' => 'dblog',
102 'granularity' => 'method',
103 'configuration' => [
104 'GET' => [
105 'supported_formats' => [
106 'json',
107 ],
108 'supported_auth' => [
109 'cookie',
110 ],
111 ],
112 ],
113 'drupal_internal__id' => 'llama',
114 ],
115 ],
116 ];
117 }
118
119 /**
120 * {@inheritdoc}
121 */
122 protected function getPostDocument() {
123 // @todo Update in https://www.drupal.org/node/2300677.
124 }
125
126 }