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