5134e910a6743559b52df96a29a7171b588c5bde
[yaffs-website] / web / core / modules / system / tests / src / Functional / Rest / ActionResourceTestBase.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Rest;
4
5 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
6 use Drupal\system\Entity\Action;
7 use Drupal\user\RoleInterface;
8
9 abstract class ActionResourceTestBase extends EntityResourceTestBase {
10
11   /**
12    * {@inheritdoc}
13    */
14   public static $modules = ['user'];
15
16   /**
17    * {@inheritdoc}
18    */
19   protected static $entityTypeId = 'action';
20
21   /**
22    * @var \Drupal\system\ActionConfigEntityInterface
23    */
24   protected $entity;
25
26   /**
27    * {@inheritdoc}
28    */
29   protected function setUpAuthorization($method) {
30     $this->grantPermissionsToTestedRole(['administer actions']);
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   protected function createEntity() {
37     $action = Action::create([
38       'id' => 'user_add_role_action.' . RoleInterface::ANONYMOUS_ID,
39       'type' => 'user',
40       'label' => t('Add the anonymous role to the selected users'),
41       'configuration' => [
42         'rid' => RoleInterface::ANONYMOUS_ID,
43       ],
44       'plugin' => 'user_add_role_action',
45     ]);
46     $action->save();
47
48     return $action;
49   }
50
51   /**
52    * {@inheritdoc}
53    */
54   protected function getExpectedNormalizedEntity() {
55     return [
56       'configuration' => [
57         'rid' => 'anonymous',
58       ],
59       'dependencies' => [
60         'config' => ['user.role.anonymous'],
61         'module' => ['user'],
62       ],
63       'id' => 'user_add_role_action.anonymous',
64       'label' => 'Add the anonymous role to the selected users',
65       'langcode' => 'en',
66       'plugin' => 'user_add_role_action',
67       'status' => TRUE,
68       'type' => 'user',
69       'uuid' => $this->entity->uuid(),
70     ];
71   }
72
73   /**
74    * {@inheritdoc}
75    */
76   protected function getExpectedCacheContexts() {
77     return [
78       'user.permissions',
79     ];
80   }
81
82   /**
83    * {@inheritdoc}
84    */
85   protected function getNormalizedPostEntity() {
86     // @todo Update in https://www.drupal.org/node/2300677.
87   }
88
89 }