Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/jsonapi/tests/src/Functional/ConfigTestTest.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\config_test\Entity\ConfigTest; | |
6 use Drupal\Core\Url; | |
7 | |
8 /** | |
9 * JSON:API integration test for the "ConfigTest" config entity type. | |
10 * | |
11 * @group jsonapi | |
12 */ | |
13 class ConfigTestTest extends ResourceTestBase { | |
14 | |
15 /** | |
16 * {@inheritdoc} | |
17 */ | |
18 public static $modules = ['config_test', 'config_test_rest']; | |
19 | |
20 /** | |
21 * {@inheritdoc} | |
22 */ | |
23 protected static $entityTypeId = 'config_test'; | |
24 | |
25 /** | |
26 * {@inheritdoc} | |
27 */ | |
28 protected static $resourceTypeName = 'config_test--config_test'; | |
29 | |
30 /** | |
31 * {@inheritdoc} | |
32 * | |
33 * @var \Drupal\config_test\ConfigTestInterface | |
34 */ | |
35 protected $entity; | |
36 | |
37 /** | |
38 * {@inheritdoc} | |
39 */ | |
40 protected function setUpAuthorization($method) { | |
41 $this->grantPermissionsToTestedRole(['view config_test']); | |
42 } | |
43 | |
44 /** | |
45 * {@inheritdoc} | |
46 */ | |
47 protected function getExpectedUnauthorizedAccessMessage($method) { | |
48 switch ($method) { | |
49 case 'GET': | |
50 return "The 'view config_test' permission is required."; | |
51 | |
52 default: | |
53 return parent::getExpectedUnauthorizedAccessMessage($method); | |
54 } | |
55 } | |
56 | |
57 /** | |
58 * {@inheritdoc} | |
59 */ | |
60 protected function createEntity() { | |
61 $config_test = ConfigTest::create([ | |
62 'id' => 'llama', | |
63 'label' => 'Llama', | |
64 ]); | |
65 $config_test->save(); | |
66 | |
67 return $config_test; | |
68 } | |
69 | |
70 /** | |
71 * {@inheritdoc} | |
72 */ | |
73 protected function getExpectedDocument() { | |
74 $self_url = Url::fromUri('base:/jsonapi/config_test/config_test/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl(); | |
75 return [ | |
76 'jsonapi' => [ | |
77 'meta' => [ | |
78 'links' => [ | |
79 'self' => ['href' => 'http://jsonapi.org/format/1.0/'], | |
80 ], | |
81 ], | |
82 'version' => '1.0', | |
83 ], | |
84 'links' => [ | |
85 'self' => ['href' => $self_url], | |
86 ], | |
87 'data' => [ | |
88 'id' => $this->entity->uuid(), | |
89 'type' => 'config_test--config_test', | |
90 'links' => [ | |
91 'self' => ['href' => $self_url], | |
92 ], | |
93 'attributes' => [ | |
94 'weight' => 0, | |
95 'langcode' => 'en', | |
96 'status' => TRUE, | |
97 'dependencies' => [], | |
98 'label' => 'Llama', | |
99 'style' => NULL, | |
100 'size' => NULL, | |
101 'size_value' => NULL, | |
102 'protected_property' => NULL, | |
103 'drupal_internal__id' => 'llama', | |
104 ], | |
105 ], | |
106 ]; | |
107 } | |
108 | |
109 /** | |
110 * {@inheritdoc} | |
111 */ | |
112 protected function getPostDocument() { | |
113 // @todo Update in https://www.drupal.org/node/2300677. | |
114 } | |
115 | |
116 } |