More updates to stop using dev or alpha or beta versions.
[yaffs-website] / web / core / modules / rest / tests / src / Functional / EntityResource / Tour / TourResourceTestBase.php
1 <?php
2
3 namespace Drupal\Tests\rest\Functional\EntityResource\Tour;
4
5 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
6 use Drupal\tour\Entity\Tour;
7
8 abstract class TourResourceTestBase extends EntityResourceTestBase {
9
10   /**
11    * {@inheritdoc}
12    */
13   public static $modules = ['tour'];
14
15   /**
16    * {@inheritdoc}
17    */
18   protected static $entityTypeId = 'tour';
19
20   /**
21    * @var \Drupal\tour\TourInterface
22    */
23   protected $entity;
24
25   /**
26    * {@inheritdoc}
27    */
28   protected function setUpAuthorization($method) {
29     $this->grantPermissionsToTestedRole(['access tour']);
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   protected function createEntity() {
36     $tour = Tour::create([
37       'id' => 'tour-llama',
38       'label' => 'Llama tour',
39       'langcode' => 'en',
40       'module' => 'tour',
41       'routes' => [
42         [
43           'route_name' => '<front>',
44         ],
45       ],
46       'tips' => [
47         'tour-llama-1' => [
48           'id' => 'tour-llama-1',
49           'plugin' => 'text',
50           'label' => 'Llama',
51           'body' => 'Who handle the awesomeness of llamas?',
52           'weight' => 100,
53           'attributes' => [
54             'data-id' => 'tour-llama-1',
55           ],
56         ],
57       ],
58     ]);
59     $tour->save();
60
61     return $tour;
62   }
63
64   /**
65    * {@inheritdoc}
66    */
67   protected function getExpectedNormalizedEntity() {
68     return [
69       'dependencies' => [],
70       'id' => 'tour-llama',
71       'label' => 'Llama tour',
72       'langcode' => 'en',
73       'module' => 'tour',
74       'routes' => [
75         [
76           'route_name' => '<front>',
77         ],
78       ],
79       'status' => TRUE,
80       'tips' => [
81         'tour-llama-1' => [
82           'id' => 'tour-llama-1',
83           'plugin' => 'text',
84           'label' => 'Llama',
85           'body' => 'Who handle the awesomeness of llamas?',
86           'weight' => 100,
87           'attributes' => [
88             'data-id' => 'tour-llama-1',
89           ],
90         ],
91       ],
92       'uuid' => $this->entity->uuid(),
93     ];
94   }
95
96   /**
97    * {@inheritdoc}
98    */
99   protected function getNormalizedPostEntity() {
100     // @todo Update in https://www.drupal.org/node/2300677.
101   }
102
103   /**
104    * {@inheritdoc}
105    */
106   protected function getExpectedCacheContexts() {
107     return [
108       'user.permissions',
109     ];
110   }
111
112   /**
113    * {@inheritdoc}
114    */
115   protected function getExpectedUnauthorizedAccessMessage($method) {
116     if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
117       return parent::getExpectedUnauthorizedAccessMessage($method);
118     }
119
120     return "The following permissions are required: 'access tour' OR 'administer site configuration'.";
121   }
122
123 }