Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / rest / tests / src / Functional / EntityResource / ShortcutSet / ShortcutSetResourceTestBase.php
1 <?php
2
3 namespace Drupal\Tests\rest\Functional\EntityResource\ShortcutSet;
4
5 use Drupal\shortcut\Entity\ShortcutSet;
6 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
7
8 /**
9  * ResourceTestBase for ShortcutSet entity.
10  */
11 abstract class ShortcutSetResourceTestBase extends EntityResourceTestBase {
12
13   /**
14    * {@inheritdoc}
15    */
16   public static $modules = ['shortcut'];
17
18   /**
19    * {@inheritdoc}
20    */
21   protected static $entityTypeId = 'shortcut_set';
22
23   /**
24    * {@inheritdoc}
25    */
26   protected static $patchProtectedFieldNames = [];
27
28   /**
29    * The ShortcutSet entity.
30    *
31    * @var \Drupal\shortcut\ShortcutSetInterface
32    */
33   protected $entity;
34
35   /**
36    * {@inheritdoc}
37    */
38   protected function setUpAuthorization($method) {
39     switch ($method) {
40       case 'GET':
41         $this->grantPermissionsToTestedRole(['access shortcuts']);
42         break;
43
44       case 'POST':
45       case 'PATCH':
46         $this->grantPermissionsToTestedRole(['access shortcuts', 'customize shortcut links']);
47         break;
48
49       case 'DELETE':
50         $this->grantPermissionsToTestedRole(['administer shortcuts']);
51         break;
52     }
53   }
54
55   /**
56    * {@inheritdoc}
57    */
58   protected function createEntity() {
59     $set = ShortcutSet::create([
60       'id' => 'llama_set',
61       'label' => 'Llama Set',
62     ]);
63     $set->save();
64     return $set;
65   }
66
67   /**
68    * {@inheritdoc}
69    */
70   protected function getExpectedNormalizedEntity() {
71     return [
72       'id' => 'llama_set',
73       'uuid' => $this->entity->uuid(),
74       'label' => 'Llama Set',
75       'status' => TRUE,
76       'langcode' => 'en',
77       'dependencies' => [],
78     ];
79   }
80
81   /**
82    * {@inheritdoc}
83    */
84   protected function getNormalizedPostEntity() {
85     // @todo Update in https://www.drupal.org/node/2300677.
86   }
87
88 }