Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / content_moderation / tests / src / Kernel / ContentModerationPermissionsTest.php
1 <?php
2
3 namespace Drupal\Tests\content_moderation\Kernel;
4
5 use Drupal\content_moderation\Permissions;
6 use Drupal\KernelTests\KernelTestBase;
7 use Drupal\workflows\Entity\Workflow;
8
9 /**
10  * Test to ensure content moderation permissions are generated correctly.
11  *
12  * @group content_moderation
13  */
14 class ContentModerationPermissionsTest extends KernelTestBase {
15
16   /**
17    * Modules to install.
18    *
19    * @var array
20    */
21   public static $modules = [
22     'workflows',
23     'content_moderation',
24     'workflow_type_test',
25   ];
26
27   /**
28    * {@inheritdoc}
29    */
30   protected function setUp() {
31     parent::setUp();
32     $this->installEntitySchema('workflow');
33   }
34
35   /**
36    * Test permissions generated by content moderation.
37    *
38    * @dataProvider permissionsTestCases
39    */
40   public function testPermissions($workflow, $permissions) {
41     Workflow::create($workflow)->save();
42     $this->assertEquals($permissions, (new Permissions())->transitionPermissions());
43   }
44
45   /**
46    * Test cases for ::testPermissions
47    *
48    * @return array
49    *   Content moderation permissions based test cases.
50    */
51   public function permissionsTestCases() {
52     return [
53       'Simple Content Moderation Workflow' => [
54         [
55           'id' => 'simple_workflow',
56           'label' => 'Simple Workflow',
57           'type' => 'content_moderation',
58         ],
59         [
60           'use simple_workflow transition publish' => [
61             'title' => '<em class="placeholder">Simple Workflow</em> workflow: Use <em class="placeholder">Publish</em> transition.',
62           ],
63           'use simple_workflow transition create_new_draft' => [
64             'title' => '<em class="placeholder">Simple Workflow</em> workflow: Use <em class="placeholder">Create New Draft</em> transition.',
65           ],
66         ],
67       ],
68       'Non Content Moderation Workflow' => [
69         [
70           'id' => 'morning',
71           'label' => 'Morning',
72           'type' => 'workflow_type_test',
73           'transitions' => [
74             'drink_coffee' => [
75               'label' => 'Drink Coffee',
76               'from' => ['tired'],
77               'to' => 'awake',
78               'weight' => 0,
79             ],
80           ],
81           'states' => [
82             'awake' => [
83               'label' => 'Awake',
84               'weight' => -5,
85             ],
86             'tired' => [
87               'label' => 'Tired',
88               'weight' => -0,
89             ],
90           ],
91         ],
92         []
93       ],
94     ];
95   }
96
97 }