Commit 34637de7 authored by catch's avatar catch

Issue #2952307 by chr.fritsch, Sam152, timmillwood: Move workflow config into standard profile

parent e60979f1
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace Drupal\Tests\book\Functional; namespace Drupal\Tests\book\Functional;
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
use Drupal\workflows\Entity\Workflow; use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
/** /**
* Tests Book and Content Moderation integration. * Tests Book and Content Moderation integration.
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
class BookContentModerationTest extends BrowserTestBase { class BookContentModerationTest extends BrowserTestBase {
use BookTestTrait; use BookTestTrait;
use ContentModerationTestTrait;
/** /**
* Modules to install. * Modules to install.
...@@ -30,7 +31,7 @@ protected function setUp() { ...@@ -30,7 +31,7 @@ protected function setUp() {
$this->drupalPlaceBlock('system_breadcrumb_block'); $this->drupalPlaceBlock('system_breadcrumb_block');
$this->drupalPlaceBlock('page_title_block'); $this->drupalPlaceBlock('page_title_block');
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'book'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'book');
$workflow->save(); $workflow->save();
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace Drupal\Tests\content_moderation\Functional; namespace Drupal\Tests\content_moderation\Functional;
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
use Drupal\workflows\Entity\Workflow; use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
/** /**
* Tests moderated content administration page functionality. * Tests moderated content administration page functionality.
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
*/ */
class ModeratedContentViewTest extends BrowserTestBase { class ModeratedContentViewTest extends BrowserTestBase {
use ContentModerationTestTrait;
/** /**
* A user with permission to bypass access content. * A user with permission to bypass access content.
* *
...@@ -34,7 +36,7 @@ public function setUp() { ...@@ -34,7 +36,7 @@ public function setUp() {
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article'])->save(); $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article'])->save();
$this->drupalCreateContentType(['type' => 'unmoderated_type', 'name' => 'Unmoderated type'])->save(); $this->drupalCreateContentType(['type' => 'unmoderated_type', 'name' => 'Unmoderated type'])->save();
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'page'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'page');
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'article'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'article');
$workflow->save(); $workflow->save();
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
use Drupal\node\Entity\Node; use Drupal\node\Entity\Node;
use Drupal\simpletest\ContentTypeCreationTrait; use Drupal\simpletest\ContentTypeCreationTrait;
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
use Drupal\workflows\Entity\Workflow; use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
/** /**
* Test the content moderation actions. * Test the content moderation actions.
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
class ModerationActionsTest extends BrowserTestBase { class ModerationActionsTest extends BrowserTestBase {
use ContentTypeCreationTrait; use ContentTypeCreationTrait;
use ContentModerationTestTrait;
/** /**
* Modules to enable. * Modules to enable.
...@@ -38,7 +39,7 @@ public function setUp() { ...@@ -38,7 +39,7 @@ public function setUp() {
$standard_bundle = $this->createContentType(['type' => 'standard_bundle']); $standard_bundle = $this->createContentType(['type' => 'standard_bundle']);
$standard_bundle->save(); $standard_bundle->save();
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'moderated_bundle'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'moderated_bundle');
$workflow->save(); $workflow->save();
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace Drupal\Tests\content_moderation\Functional; namespace Drupal\Tests\content_moderation\Functional;
use Drupal\Core\Entity\Entity\EntityFormDisplay; use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\workflows\Entity\Workflow;
use Drupal\Core\Url; use Drupal\Core\Url;
/** /**
...@@ -157,9 +156,8 @@ public function testModerationForm() { ...@@ -157,9 +156,8 @@ public function testModerationForm() {
*/ */
public function testNonBundleModerationForm() { public function testNonBundleModerationForm() {
$this->drupalLogin($this->rootUser); $this->drupalLogin($this->rootUser);
$workflow = Workflow::load('editorial'); $this->workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_mulrevpub', 'entity_test_mulrevpub');
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_mulrevpub', 'entity_test_mulrevpub'); $this->workflow->save();
$workflow->save();
// Create new moderated content in draft. // Create new moderated content in draft.
$this->drupalPostForm('entity_test_mulrevpub/add', ['moderation_state[0][state]' => 'draft'], t('Save')); $this->drupalPostForm('entity_test_mulrevpub/add', ['moderation_state[0][state]' => 'draft'], t('Save'));
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
use Drupal\simpletest\ContentTypeCreationTrait; use Drupal\simpletest\ContentTypeCreationTrait;
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
use Drupal\workflows\Entity\Workflow; use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
/** /**
* Test revision revert. * Test revision revert.
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
class ModerationRevisionRevertTest extends BrowserTestBase { class ModerationRevisionRevertTest extends BrowserTestBase {
use ContentTypeCreationTrait; use ContentTypeCreationTrait;
use ContentModerationTestTrait;
/** /**
* Modules to enable. * Modules to enable.
...@@ -34,7 +35,7 @@ public function setUp() { ...@@ -34,7 +35,7 @@ public function setUp() {
$moderated_bundle = $this->createContentType(['type' => 'moderated_bundle']); $moderated_bundle = $this->createContentType(['type' => 'moderated_bundle']);
$moderated_bundle->save(); $moderated_bundle->save();
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'moderated_bundle'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'moderated_bundle');
$workflow->save(); $workflow->save();
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
use Drupal\node\Entity\Node; use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType; use Drupal\node\Entity\NodeType;
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
use Drupal\workflows\Entity\Workflow; use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
/** /**
* Tests the view access control handler for moderation state entities. * Tests the view access control handler for moderation state entities.
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
*/ */
class ModerationStateAccessTest extends BrowserTestBase { class ModerationStateAccessTest extends BrowserTestBase {
use ContentModerationTestTrait;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -99,7 +101,7 @@ protected function createNodeType($label, $machine_name) { ...@@ -99,7 +101,7 @@ protected function createNodeType($label, $machine_name) {
]); ]);
$node_type->save(); $node_type->save();
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', $machine_name); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', $machine_name);
$workflow->save(); $workflow->save();
return $node_type; return $node_type;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\node\Entity\NodeType; use Drupal\node\Entity\NodeType;
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
use Drupal\user\Entity\Role; use Drupal\user\Entity\Role;
/** /**
...@@ -12,6 +13,8 @@ ...@@ -12,6 +13,8 @@
*/ */
abstract class ModerationStateTestBase extends BrowserTestBase { abstract class ModerationStateTestBase extends BrowserTestBase {
use ContentModerationTestTrait;
/** /**
* Profile to use. * Profile to use.
* *
...@@ -46,6 +49,13 @@ abstract class ModerationStateTestBase extends BrowserTestBase { ...@@ -46,6 +49,13 @@ abstract class ModerationStateTestBase extends BrowserTestBase {
'use editorial transition archived_published', 'use editorial transition archived_published',
]; ];
/**
* The editorial workflow entity.
*
* @var \Drupal\workflows\Entity\Workflow
*/
protected $workflow;
/** /**
* Modules to enable. * Modules to enable.
* *
...@@ -64,6 +74,7 @@ abstract class ModerationStateTestBase extends BrowserTestBase { ...@@ -64,6 +74,7 @@ abstract class ModerationStateTestBase extends BrowserTestBase {
*/ */
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->workflow = $this->createEditorialWorkflow();
$this->adminUser = $this->drupalCreateUser($this->permissions); $this->adminUser = $this->drupalCreateUser($this->permissions);
$this->drupalPlaceBlock('local_tasks_block', ['id' => 'tabs_block']); $this->drupalPlaceBlock('local_tasks_block', ['id' => 'tabs_block']);
$this->drupalPlaceBlock('page_title_block'); $this->drupalPlaceBlock('page_title_block');
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\Tests\content_moderation\Functional; namespace Drupal\Tests\content_moderation\Functional;
use Drupal\node\Entity\NodeType; use Drupal\node\Entity\NodeType;
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
use Drupal\Tests\views\Functional\ViewTestBase; use Drupal\Tests\views\Functional\ViewTestBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Views; use Drupal\views\Views;
...@@ -17,6 +18,8 @@ ...@@ -17,6 +18,8 @@
*/ */
class ViewsModerationStateFilterTest extends ViewTestBase { class ViewsModerationStateFilterTest extends ViewTestBase {
use ContentModerationTestTrait;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -45,6 +48,8 @@ protected function setUp($import_test_views = TRUE) { ...@@ -45,6 +48,8 @@ protected function setUp($import_test_views = TRUE) {
'type' => 'example_b', 'type' => 'example_b',
])->save(); ])->save();
$this->createEditorialWorkflow();
$new_workflow = Workflow::create([ $new_workflow = Workflow::create([
'type' => 'content_moderation', 'type' => 'content_moderation',
'id' => 'new_workflow', 'id' => 'new_workflow',
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
use Drupal\node\Entity\Node; use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType; use Drupal\node\Entity\NodeType;
use Drupal\workflows\Entity\Workflow; use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
/** /**
* Test the ContentModerationState storage schema. * Test the ContentModerationState storage schema.
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
*/ */
class ContentModerationStateStorageSchemaTest extends KernelTestBase { class ContentModerationStateStorageSchemaTest extends KernelTestBase {
use ContentModerationTestTrait;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -45,7 +47,7 @@ protected function setUp() { ...@@ -45,7 +47,7 @@ protected function setUp() {
NodeType::create([ NodeType::create([
'type' => 'example', 'type' => 'example',
])->save(); ])->save();
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
$workflow->save(); $workflow->save();
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
use Drupal\language\Entity\ConfigurableLanguage; use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Entity\Node; use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType; use Drupal\node\Entity\NodeType;
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
use Drupal\workflows\Entity\Workflow; use Drupal\workflows\Entity\Workflow;
/** /**
...@@ -21,6 +22,8 @@ ...@@ -21,6 +22,8 @@
*/ */
class ContentModerationStateTest extends KernelTestBase { class ContentModerationStateTest extends KernelTestBase {
use ContentModerationTestTrait;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -275,7 +278,7 @@ public function testMultilingualModeration() { ...@@ -275,7 +278,7 @@ public function testMultilingualModeration() {
]); ]);
$node_type->save(); $node_type->save();
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
$workflow->save(); $workflow->save();
...@@ -388,7 +391,7 @@ public function testModerationWithFieldConfigOverride() { ...@@ -388,7 +391,7 @@ public function testModerationWithFieldConfigOverride() {
'type' => 'test_type', 'type' => 'test_type',
])->save(); ])->save();
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'test_type'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'test_type');
$workflow->save(); $workflow->save();
...@@ -415,7 +418,7 @@ public function testModerationWithFieldConfigOverride() { ...@@ -415,7 +418,7 @@ public function testModerationWithFieldConfigOverride() {
* Tests that entities with special languages can be moderated. * Tests that entities with special languages can be moderated.
*/ */
public function testModerationWithSpecialLanguages() { public function testModerationWithSpecialLanguages() {
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev'); $workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev');
$workflow->save(); $workflow->save();
...@@ -436,7 +439,7 @@ public function testModerationWithSpecialLanguages() { ...@@ -436,7 +439,7 @@ public function testModerationWithSpecialLanguages() {
* Tests that a non-translatable entity type with a langcode can be moderated. * Tests that a non-translatable entity type with a langcode can be moderated.
*/ */
public function testNonTranslatableEntityTypeModeration() { public function testNonTranslatableEntityTypeModeration() {
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev'); $workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev');
$workflow->save(); $workflow->save();
...@@ -470,7 +473,7 @@ public function testNonLangcodeEntityTypeModeration() { ...@@ -470,7 +473,7 @@ public function testNonLangcodeEntityTypeModeration() {
// Update the entity type in order to remove the 'langcode' field. // Update the entity type in order to remove the 'langcode' field.
\Drupal::entityDefinitionUpdateManager()->applyUpdates(); \Drupal::entityDefinitionUpdateManager()->applyUpdates();
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev'); $workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev');
$workflow->save(); $workflow->save();
...@@ -500,7 +503,7 @@ public function testWorkflowDependencies() { ...@@ -500,7 +503,7 @@ public function testWorkflowDependencies() {
]); ]);
$node_type->save(); $node_type->save();
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
// Test both a config and non-config based bundle and entity type. // Test both a config and non-config based bundle and entity type.
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev'); $workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev');
...@@ -543,7 +546,7 @@ public function testWorkflowNonConfigBundleDependencies() { ...@@ -543,7 +546,7 @@ public function testWorkflowNonConfigBundleDependencies() {
// Create a bundle not based on any particular configuration. // Create a bundle not based on any particular configuration.
entity_test_create_bundle('test_bundle'); entity_test_create_bundle('test_bundle');
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test', 'test_bundle'); $workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test', 'test_bundle');
$workflow->save(); $workflow->save();
...@@ -653,7 +656,7 @@ protected function createEntity($entity_type_id) { ...@@ -653,7 +656,7 @@ protected function createEntity($entity_type_id) {
} }
} }
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle($entity_type_id, $bundle_id); $workflow->getTypePlugin()->addEntityTypeAndBundle($entity_type_id, $bundle_id);
$workflow->save(); $workflow->save();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
use Drupal\node\Entity\Node; use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType; use Drupal\node\Entity\NodeType;
use Drupal\workflows\Entity\Workflow; use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
/** /**
* Tests how Content Moderation handles workflow config changes. * Tests how Content Moderation handles workflow config changes.
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
*/ */
class ContentModerationWorkflowConfigTest extends KernelTestBase { class ContentModerationWorkflowConfigTest extends KernelTestBase {
use ContentModerationTestTrait;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -63,7 +65,7 @@ protected function setUp() { ...@@ -63,7 +65,7 @@ protected function setUp() {
'type' => 'example', 'type' => 'example',
])->save(); ])->save();
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin() $workflow->getTypePlugin()
->addState('test1', 'Test one') ->addState('test1', 'Test one')
->addState('test2', 'Test two') ->addState('test2', 'Test two')
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
use Drupal\language\Entity\ConfigurableLanguage; use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Entity\Node; use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType; use Drupal\node\Entity\NodeType;
use Drupal\workflows\Entity\Workflow; use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
/** /**
* Tests the correct default revision is set. * Tests the correct default revision is set.
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
*/ */
class DefaultRevisionStateTest extends KernelTestBase { class DefaultRevisionStateTest extends KernelTestBase {
use ContentModerationTestTrait;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -68,7 +70,7 @@ public function testMultilingual() { ...@@ -68,7 +70,7 @@ public function testMultilingual() {
$this->container->get('content_translation.manager')->setEnabled('node', 'example', TRUE); $this->container->get('content_translation.manager')->setEnabled('node', 'example', TRUE);
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
$workflow->save(); $workflow->save();
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
use Drupal\node\Entity\Node; use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType; use Drupal\node\Entity\NodeType;
use Drupal\workflows\Entity\Workflow; use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
/** /**
* @coversDefaultClass \Drupal\content_moderation\EntityOperations * @coversDefaultClass \Drupal\content_moderation\EntityOperations
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
*/ */
class EntityOperationsTest extends KernelTestBase { class EntityOperationsTest extends KernelTestBase {
use ContentModerationTestTrait;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -48,7 +50,7 @@ protected function createNodeType() { ...@@ -48,7 +50,7 @@ protected function createNodeType() {
'label' => 'Page', 'label' => 'Page',
]); ]);
$node_type->save(); $node_type->save();
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'page'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'page');
$workflow->save(); $workflow->save();
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
use Drupal\language\Entity\ConfigurableLanguage; use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Entity\Node; use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType; use Drupal\node\Entity\NodeType;
use Drupal\workflows\Entity\Workflow; use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
/** /**
* @coversDefaultClass \Drupal\content_moderation\Plugin\Validation\Constraint\ModerationStateConstraintValidator * @coversDefaultClass \Drupal\content_moderation\Plugin\Validation\Constraint\ModerationStateConstraintValidator
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
*/ */
class EntityStateChangeValidationTest extends KernelTestBase { class EntityStateChangeValidationTest extends KernelTestBase {
use ContentModerationTestTrait;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -50,7 +52,7 @@ public function testValidTransition() { ...@@ -50,7 +52,7 @@ public function testValidTransition() {
'type' => 'example', 'type' => 'example',
]); ]);
$node_type->save(); $node_type->save();
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
$workflow->save(); $workflow->save();
...@@ -78,7 +80,7 @@ public function testInvalidTransition() { ...@@ -78,7 +80,7 @@ public function testInvalidTransition() {
'type' => 'example', 'type' => 'example',
]); ]);
$node_type->save(); $node_type->save();
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
$workflow->save(); $workflow->save();
...@@ -104,7 +106,7 @@ public function testInvalidState() { ...@@ -104,7 +106,7 @@ public function testInvalidState() {
'type' => 'example', 'type' => 'example',
]); ]);
$node_type->save(); $node_type->save();
$workflow = Workflow::load('editorial'); $workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
$workflow->save(); $workflow->save();