Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / views / tests / src / Functional / Rest / ViewResourceTestBase.php
1 <?php
2
3 namespace Drupal\Tests\views\Functional\Rest;
4
5 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
6 use Drupal\views\Entity\View;
7
8 abstract class ViewResourceTestBase extends EntityResourceTestBase {
9
10   /**
11    * {@inheritdoc}
12    */
13   public static $modules = ['views'];
14
15   /**
16    * {@inheritdoc}
17    */
18   protected static $entityTypeId = 'view';
19
20   /**
21    * @var \Drupal\views\ViewEntityInterface
22    */
23   protected $entity;
24
25   /**
26    * {@inheritdoc}
27    */
28   protected function setUpAuthorization($method) {
29     $this->grantPermissionsToTestedRole(['administer views']);
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   protected function createEntity() {
36     $view = View::create([
37       'id' => 'test_rest',
38       'label' => 'Test REST',
39     ]);
40     $view->save();
41     return $view;
42   }
43
44   /**
45    * {@inheritdoc}
46    */
47   protected function getExpectedNormalizedEntity() {
48     return [
49       'base_field' => 'nid',
50       'base_table' => 'node',
51       'core' => '8.x',
52       'dependencies' => [],
53       'description' => '',
54       'display' => [
55         'default' => [
56           'display_plugin' => 'default',
57           'id' => 'default',
58           'display_title' => 'Master',
59           'position' => 0,
60           'display_options' => [
61             'display_extenders' => [],
62           ],
63           'cache_metadata' => [
64             'max-age' => -1,
65             'contexts' => [
66               'languages:language_interface',
67               'url.query_args',
68             ],
69             'tags' => [],
70           ],
71         ],
72       ],
73       'id' => 'test_rest',
74       'label' => 'Test REST',
75       'langcode' => 'en',
76       'module' => 'views',
77       'status' => TRUE,
78       'tag' => '',
79       'uuid' => $this->entity->uuid(),
80     ];
81   }
82
83   /**
84    * {@inheritdoc}
85    */
86   protected function getNormalizedPostEntity() {
87     // @todo Update in https://www.drupal.org/node/2300677.
88   }
89
90   /**
91    * {@inheritdoc}
92    */
93   protected function getExpectedCacheContexts() {
94     return [
95       'user.permissions',
96     ];
97   }
98
99 }