Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / content_moderation / tests / src / Traits / ContentModerationTestTrait.php
1 <?php
2
3 namespace Drupal\Tests\content_moderation\Traits;
4
5 use Drupal\workflows\Entity\Workflow;
6
7 /**
8  * Trait ContentModerationTestTraint.
9  */
10 trait ContentModerationTestTrait {
11
12   /**
13    * Creates the editorial workflow.
14    *
15    * @return \Drupal\workflows\Entity\Workflow
16    *   The editorial workflow entity.
17    */
18   protected function createEditorialWorkflow() {
19     $workflow = Workflow::create([
20       'type' => 'content_moderation',
21       'id' => 'editorial',
22       'label' => 'Editorial',
23       'type_settings' => [
24         'states' => [
25           'archived' => [
26             'label' => 'Archived',
27             'weight' => 5,
28             'published' => FALSE,
29             'default_revision' => TRUE,
30           ],
31           'draft' => [
32             'label' => 'Draft',
33             'published' => FALSE,
34             'default_revision' => FALSE,
35             'weight' => -5,
36           ],
37           'published' => [
38             'label' => 'Published',
39             'published' => TRUE,
40             'default_revision' => TRUE,
41             'weight' => 0,
42           ],
43         ],
44         'transitions' => [
45           'archive' => [
46             'label' => 'Archive',
47             'from' => ['published'],
48             'to' => 'archived',
49             'weight' => 2,
50           ],
51           'archived_draft' => [
52             'label' => 'Restore to Draft',
53             'from' => ['archived'],
54             'to' => 'draft',
55             'weight' => 3,
56           ],
57           'archived_published' => [
58             'label' => 'Restore',
59             'from' => ['archived'],
60             'to' => 'published',
61             'weight' => 4,
62           ],
63           'create_new_draft' => [
64             'label' => 'Create New Draft',
65             'to' => 'draft',
66             'weight' => 0,
67             'from' => [
68               'draft',
69               'published',
70             ],
71           ],
72           'publish' => [
73             'label' => 'Publish',
74             'to' => 'published',
75             'weight' => 1,
76             'from' => [
77               'draft',
78               'published',
79             ],
80           ],
81         ],
82       ],
83     ]);
84     $workflow->save();
85     return $workflow;
86   }
87
88 }