Mercurial > hg > isophonics-drupal-site
comparison core/tests/Drupal/FunctionalTests/Rest/EntityFormDisplayResourceTestBase.php @ 16:c2387f117808
Routine composer update
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 15:07:59 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:e200cb7efeb3 | 16:c2387f117808 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\FunctionalTests\Rest; | |
4 | |
5 use Drupal\Core\Entity\Entity\EntityFormDisplay; | |
6 use Drupal\node\Entity\NodeType; | |
7 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase; | |
8 | |
9 abstract class EntityFormDisplayResourceTestBase extends EntityResourceTestBase { | |
10 | |
11 /** | |
12 * {@inheritdoc} | |
13 */ | |
14 public static $modules = ['node']; | |
15 | |
16 /** | |
17 * {@inheritdoc} | |
18 */ | |
19 protected static $entityTypeId = 'entity_form_display'; | |
20 | |
21 /** | |
22 * @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface | |
23 */ | |
24 protected $entity; | |
25 | |
26 /** | |
27 * {@inheritdoc} | |
28 */ | |
29 protected function setUpAuthorization($method) { | |
30 $this->grantPermissionsToTestedRole(['administer node form display']); | |
31 } | |
32 | |
33 /** | |
34 * {@inheritdoc} | |
35 */ | |
36 protected function createEntity() { | |
37 // Create a "Camelids" node type. | |
38 $camelids = NodeType::create([ | |
39 'name' => 'Camelids', | |
40 'type' => 'camelids', | |
41 ]); | |
42 | |
43 $camelids->save(); | |
44 | |
45 // Create a form display. | |
46 $form_display = EntityFormDisplay::create([ | |
47 'targetEntityType' => 'node', | |
48 'bundle' => 'camelids', | |
49 'mode' => 'default', | |
50 ]); | |
51 $form_display->save(); | |
52 | |
53 return $form_display; | |
54 } | |
55 | |
56 /** | |
57 * {@inheritdoc} | |
58 */ | |
59 protected function getExpectedNormalizedEntity() { | |
60 return [ | |
61 'bundle' => 'camelids', | |
62 'content' => [ | |
63 'created' => [ | |
64 'type' => 'datetime_timestamp', | |
65 'weight' => 10, | |
66 'region' => 'content', | |
67 'settings' => [], | |
68 'third_party_settings' => [], | |
69 ], | |
70 'promote' => [ | |
71 'type' => 'boolean_checkbox', | |
72 'settings' => [ | |
73 'display_label' => TRUE, | |
74 ], | |
75 'weight' => 15, | |
76 'region' => 'content', | |
77 'third_party_settings' => [], | |
78 ], | |
79 'status' => [ | |
80 'type' => 'boolean_checkbox', | |
81 'weight' => 120, | |
82 'region' => 'content', | |
83 'settings' => [ | |
84 'display_label' => TRUE, | |
85 ], | |
86 'third_party_settings' => [], | |
87 ], | |
88 'sticky' => [ | |
89 'type' => 'boolean_checkbox', | |
90 'settings' => [ | |
91 'display_label' => TRUE, | |
92 ], | |
93 'weight' => 16, | |
94 'region' => 'content', | |
95 'third_party_settings' => [], | |
96 ], | |
97 'title' => [ | |
98 'type' => 'string_textfield', | |
99 'weight' => -5, | |
100 'region' => 'content', | |
101 'settings' => [ | |
102 'size' => 60, | |
103 'placeholder' => '', | |
104 ], | |
105 'third_party_settings' => [], | |
106 ], | |
107 'uid' => [ | |
108 'type' => 'entity_reference_autocomplete', | |
109 'weight' => 5, | |
110 'settings' => [ | |
111 'match_operator' => 'CONTAINS', | |
112 'size' => 60, | |
113 'placeholder' => '', | |
114 ], | |
115 'region' => 'content', | |
116 'third_party_settings' => [], | |
117 ], | |
118 ], | |
119 'dependencies' => [ | |
120 'config' => [ | |
121 'node.type.camelids', | |
122 ], | |
123 ], | |
124 'hidden' => [], | |
125 'id' => 'node.camelids.default', | |
126 'langcode' => 'en', | |
127 'mode' => 'default', | |
128 'status' => NULL, | |
129 'targetEntityType' => 'node', | |
130 'uuid' => $this->entity->uuid(), | |
131 ]; | |
132 } | |
133 | |
134 /** | |
135 * {@inheritdoc} | |
136 */ | |
137 protected function getNormalizedPostEntity() { | |
138 // @todo Update in https://www.drupal.org/node/2300677. | |
139 } | |
140 | |
141 /** | |
142 * {@inheritdoc} | |
143 */ | |
144 protected function getExpectedCacheContexts() { | |
145 return [ | |
146 'user.permissions', | |
147 ]; | |
148 } | |
149 | |
150 /** | |
151 * {@inheritdoc} | |
152 */ | |
153 protected function getExpectedUnauthorizedAccessMessage($method) { | |
154 if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) { | |
155 return parent::getExpectedUnauthorizedAccessMessage($method); | |
156 } | |
157 | |
158 return "The 'administer node form display' permission is required."; | |
159 } | |
160 | |
161 } |