comparison core/modules/jsonapi/tests/src/Functional/MenuTest.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\system\Entity\Menu;
7
8 /**
9 * JSON:API integration test for the "Menu" config entity type.
10 *
11 * @group jsonapi
12 */
13 class MenuTest extends ResourceTestBase {
14
15 /**
16 * {@inheritdoc}
17 */
18 public static $modules = [];
19
20 /**
21 * {@inheritdoc}
22 */
23 protected static $entityTypeId = 'menu';
24
25 /**
26 * {@inheritdoc}
27 */
28 protected static $resourceTypeName = 'menu--menu';
29
30 /**
31 * {@inheritdoc}
32 */
33 protected static $anonymousUsersCanViewLabels = TRUE;
34
35 /**
36 * {@inheritdoc}
37 *
38 * @var \Drupal\system\MenuInterface
39 */
40 protected $entity;
41
42 /**
43 * {@inheritdoc}
44 */
45 protected function setUpAuthorization($method) {
46 $this->grantPermissionsToTestedRole(['administer menu']);
47 }
48
49 /**
50 * {@inheritdoc}
51 */
52 protected function createEntity() {
53 $menu = Menu::create([
54 'id' => 'menu',
55 'label' => 'Menu',
56 'description' => 'Menu',
57 ]);
58 $menu->save();
59
60 return $menu;
61 }
62
63 /**
64 * {@inheritdoc}
65 */
66 protected function getExpectedDocument() {
67 $self_url = Url::fromUri('base:/jsonapi/menu/menu/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl();
68 return [
69 'jsonapi' => [
70 'meta' => [
71 'links' => [
72 'self' => ['href' => 'http://jsonapi.org/format/1.0/'],
73 ],
74 ],
75 'version' => '1.0',
76 ],
77 'links' => [
78 'self' => ['href' => $self_url],
79 ],
80 'data' => [
81 'id' => $this->entity->uuid(),
82 'type' => 'menu--menu',
83 'links' => [
84 'self' => ['href' => $self_url],
85 ],
86 'attributes' => [
87 'dependencies' => [],
88 'description' => 'Menu',
89 'label' => 'Menu',
90 'langcode' => 'en',
91 'locked' => FALSE,
92 'status' => TRUE,
93 'drupal_internal__id' => 'menu',
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 }