Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/jsonapi/tests/src/Functional/TourTest.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\tour\Entity\Tour; | |
7 | |
8 /** | |
9 * JSON:API integration test for the "Tour" config entity type. | |
10 * | |
11 * @group jsonapi | |
12 */ | |
13 class TourTest extends ResourceTestBase { | |
14 | |
15 /** | |
16 * {@inheritdoc} | |
17 */ | |
18 public static $modules = ['tour']; | |
19 | |
20 /** | |
21 * {@inheritdoc} | |
22 */ | |
23 protected static $entityTypeId = 'tour'; | |
24 | |
25 /** | |
26 * {@inheritdoc} | |
27 */ | |
28 protected static $resourceTypeName = 'tour--tour'; | |
29 | |
30 /** | |
31 * {@inheritdoc} | |
32 * | |
33 * @var \Drupal\tour\TourInterface | |
34 */ | |
35 protected $entity; | |
36 | |
37 /** | |
38 * {@inheritdoc} | |
39 */ | |
40 protected function setUpAuthorization($method) { | |
41 $this->grantPermissionsToTestedRole(['access tour']); | |
42 } | |
43 | |
44 /** | |
45 * {@inheritdoc} | |
46 */ | |
47 protected function createEntity() { | |
48 $tour = Tour::create([ | |
49 'id' => 'tour-llama', | |
50 'label' => 'Llama tour', | |
51 'langcode' => 'en', | |
52 'module' => 'tour', | |
53 'routes' => [ | |
54 [ | |
55 'route_name' => '<front>', | |
56 ], | |
57 ], | |
58 'tips' => [ | |
59 'tour-llama-1' => [ | |
60 'id' => 'tour-llama-1', | |
61 'plugin' => 'text', | |
62 'label' => 'Llama', | |
63 'body' => 'Who handle the awesomeness of llamas?', | |
64 'weight' => 100, | |
65 'attributes' => [ | |
66 'data-id' => 'tour-llama-1', | |
67 ], | |
68 ], | |
69 ], | |
70 ]); | |
71 $tour->save(); | |
72 | |
73 return $tour; | |
74 } | |
75 | |
76 /** | |
77 * {@inheritdoc} | |
78 */ | |
79 protected function getExpectedDocument() { | |
80 $self_url = Url::fromUri('base:/jsonapi/tour/tour/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl(); | |
81 return [ | |
82 'jsonapi' => [ | |
83 'meta' => [ | |
84 'links' => [ | |
85 'self' => ['href' => 'http://jsonapi.org/format/1.0/'], | |
86 ], | |
87 ], | |
88 'version' => '1.0', | |
89 ], | |
90 'links' => [ | |
91 'self' => ['href' => $self_url], | |
92 ], | |
93 'data' => [ | |
94 'id' => $this->entity->uuid(), | |
95 'type' => 'tour--tour', | |
96 'links' => [ | |
97 'self' => ['href' => $self_url], | |
98 ], | |
99 'attributes' => [ | |
100 'dependencies' => [], | |
101 'label' => 'Llama tour', | |
102 'langcode' => 'en', | |
103 'module' => 'tour', | |
104 'routes' => [ | |
105 [ | |
106 'route_name' => '<front>', | |
107 ], | |
108 ], | |
109 'status' => TRUE, | |
110 'tips' => [ | |
111 'tour-llama-1' => [ | |
112 'id' => 'tour-llama-1', | |
113 'plugin' => 'text', | |
114 'label' => 'Llama', | |
115 'body' => 'Who handle the awesomeness of llamas?', | |
116 'weight' => 100, | |
117 'attributes' => [ | |
118 'data-id' => 'tour-llama-1', | |
119 ], | |
120 ], | |
121 ], | |
122 'drupal_internal__id' => 'tour-llama', | |
123 ], | |
124 ], | |
125 ]; | |
126 } | |
127 | |
128 /** | |
129 * {@inheritdoc} | |
130 */ | |
131 protected function getPostDocument() { | |
132 // @todo Update in https://www.drupal.org/node/2300677. | |
133 } | |
134 | |
135 /** | |
136 * {@inheritdoc} | |
137 */ | |
138 protected function getExpectedUnauthorizedAccessMessage($method) { | |
139 return "The following permissions are required: 'access tour' OR 'administer site configuration'."; | |
140 } | |
141 | |
142 } |