comparison core/modules/jsonapi/tests/src/Functional/ViewTest.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\views\Entity\View;
7
8 /**
9 * JSON:API integration test for the "View" config entity type.
10 *
11 * @group jsonapi
12 */
13 class ViewTest extends ResourceTestBase {
14
15 /**
16 * {@inheritdoc}
17 */
18 public static $modules = ['views'];
19
20 /**
21 * {@inheritdoc}
22 */
23 protected static $entityTypeId = 'view';
24
25 /**
26 * {@inheritdoc}
27 */
28 protected static $resourceTypeName = 'view--view';
29
30 /**
31 * {@inheritdoc}
32 *
33 * @var \Drupal\views\ViewEntityInterface
34 */
35 protected $entity;
36
37 /**
38 * {@inheritdoc}
39 */
40 protected function setUpAuthorization($method) {
41 $this->grantPermissionsToTestedRole(['administer views']);
42 }
43
44 /**
45 * {@inheritdoc}
46 */
47 protected function createEntity() {
48 $view = View::create([
49 'id' => 'test_rest',
50 'label' => 'Test REST',
51 ]);
52 $view->save();
53 return $view;
54 }
55
56 /**
57 * {@inheritdoc}
58 */
59 protected function getExpectedDocument() {
60 $self_url = Url::fromUri('base:/jsonapi/view/view/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl();
61 return [
62 'jsonapi' => [
63 'meta' => [
64 'links' => [
65 'self' => ['href' => 'http://jsonapi.org/format/1.0/'],
66 ],
67 ],
68 'version' => '1.0',
69 ],
70 'links' => [
71 'self' => ['href' => $self_url],
72 ],
73 'data' => [
74 'id' => $this->entity->uuid(),
75 'type' => 'view--view',
76 'links' => [
77 'self' => ['href' => $self_url],
78 ],
79 'attributes' => [
80 'base_field' => 'nid',
81 'base_table' => 'node',
82 'core' => '8.x',
83 'dependencies' => [],
84 'description' => '',
85 'display' => [
86 'default' => [
87 'display_plugin' => 'default',
88 'id' => 'default',
89 'display_title' => 'Master',
90 'position' => 0,
91 'display_options' => [
92 'display_extenders' => [],
93 ],
94 'cache_metadata' => [
95 'max-age' => -1,
96 'contexts' => [
97 'languages:language_interface',
98 'url.query_args',
99 ],
100 'tags' => [],
101 ],
102 ],
103 ],
104 'label' => 'Test REST',
105 'langcode' => 'en',
106 'module' => 'views',
107 'status' => TRUE,
108 'tag' => '',
109 'drupal_internal__id' => 'test_rest',
110 ],
111 ],
112 ];
113 }
114
115 /**
116 * {@inheritdoc}
117 */
118 protected function getPostDocument() {
119 // @todo Update in https://www.drupal.org/node/2300677.
120 }
121
122 }