Issue #2952307 by chr.fritsch, Sam152, timmillwood: Move workflow config into standard profile
parent
e60979f160
commit
34637de7aa
|
@ -3,7 +3,7 @@
|
|||
namespace Drupal\Tests\book\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Tests Book and Content Moderation integration.
|
||||
|
@ -13,6 +13,7 @@ use Drupal\workflows\Entity\Workflow;
|
|||
class BookContentModerationTest extends BrowserTestBase {
|
||||
|
||||
use BookTestTrait;
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
|
@ -30,7 +31,7 @@ class BookContentModerationTest extends BrowserTestBase {
|
|||
$this->drupalPlaceBlock('system_breadcrumb_block');
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'book');
|
||||
$workflow->save();
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Drupal\Tests\content_moderation\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Tests moderated content administration page functionality.
|
||||
|
@ -12,6 +12,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class ModeratedContentViewTest extends BrowserTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* A user with permission to bypass access content.
|
||||
*
|
||||
|
@ -34,7 +36,7 @@ class ModeratedContentViewTest extends BrowserTestBase {
|
|||
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article'])->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', 'article');
|
||||
$workflow->save();
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Drupal\Tests\content_moderation\Functional;
|
|||
use Drupal\node\Entity\Node;
|
||||
use Drupal\simpletest\ContentTypeCreationTrait;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Test the content moderation actions.
|
||||
|
@ -15,6 +15,7 @@ use Drupal\workflows\Entity\Workflow;
|
|||
class ModerationActionsTest extends BrowserTestBase {
|
||||
|
||||
use ContentTypeCreationTrait;
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -38,7 +39,7 @@ class ModerationActionsTest extends BrowserTestBase {
|
|||
$standard_bundle = $this->createContentType(['type' => 'standard_bundle']);
|
||||
$standard_bundle->save();
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'moderated_bundle');
|
||||
$workflow->save();
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Drupal\Tests\content_moderation\Functional;
|
||||
|
||||
use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Core\Url;
|
||||
|
||||
/**
|
||||
|
@ -157,9 +156,8 @@ class ModerationFormTest extends ModerationStateTestBase {
|
|||
*/
|
||||
public function testNonBundleModerationForm() {
|
||||
$this->drupalLogin($this->rootUser);
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_mulrevpub', 'entity_test_mulrevpub');
|
||||
$workflow->save();
|
||||
$this->workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_mulrevpub', 'entity_test_mulrevpub');
|
||||
$this->workflow->save();
|
||||
|
||||
// Create new moderated content in draft.
|
||||
$this->drupalPostForm('entity_test_mulrevpub/add', ['moderation_state[0][state]' => 'draft'], t('Save'));
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Drupal\Tests\content_moderation\Functional;
|
|||
|
||||
use Drupal\simpletest\ContentTypeCreationTrait;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Test revision revert.
|
||||
|
@ -14,6 +14,7 @@ use Drupal\workflows\Entity\Workflow;
|
|||
class ModerationRevisionRevertTest extends BrowserTestBase {
|
||||
|
||||
use ContentTypeCreationTrait;
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -34,7 +35,7 @@ class ModerationRevisionRevertTest extends BrowserTestBase {
|
|||
$moderated_bundle = $this->createContentType(['type' => 'moderated_bundle']);
|
||||
$moderated_bundle->save();
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'moderated_bundle');
|
||||
$workflow->save();
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Drupal\Tests\content_moderation\Functional;
|
|||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
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.
|
||||
|
@ -14,6 +14,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class ModerationStateAccessTest extends BrowserTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -99,7 +101,7 @@ class ModerationStateAccessTest extends BrowserTestBase {
|
|||
]);
|
||||
$node_type->save();
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', $machine_name);
|
||||
$workflow->save();
|
||||
return $node_type;
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Drupal\Tests\content_moderation\Functional;
|
|||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
use Drupal\user\Entity\Role;
|
||||
|
||||
/**
|
||||
|
@ -12,6 +13,8 @@ use Drupal\user\Entity\Role;
|
|||
*/
|
||||
abstract class ModerationStateTestBase extends BrowserTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Profile to use.
|
||||
*
|
||||
|
@ -46,6 +49,13 @@ abstract class ModerationStateTestBase extends BrowserTestBase {
|
|||
'use editorial transition archived_published',
|
||||
];
|
||||
|
||||
/**
|
||||
* The editorial workflow entity.
|
||||
*
|
||||
* @var \Drupal\workflows\Entity\Workflow
|
||||
*/
|
||||
protected $workflow;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
@ -64,6 +74,7 @@ abstract class ModerationStateTestBase extends BrowserTestBase {
|
|||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->workflow = $this->createEditorialWorkflow();
|
||||
$this->adminUser = $this->drupalCreateUser($this->permissions);
|
||||
$this->drupalPlaceBlock('local_tasks_block', ['id' => 'tabs_block']);
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Drupal\Tests\content_moderation\Functional;
|
||||
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
use Drupal\views\ViewExecutable;
|
||||
use Drupal\views\Views;
|
||||
|
@ -17,6 +18,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class ViewsModerationStateFilterTest extends ViewTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -45,6 +48,8 @@ class ViewsModerationStateFilterTest extends ViewTestBase {
|
|||
'type' => 'example_b',
|
||||
])->save();
|
||||
|
||||
$this->createEditorialWorkflow();
|
||||
|
||||
$new_workflow = Workflow::create([
|
||||
'type' => 'content_moderation',
|
||||
'id' => 'new_workflow',
|
||||
|
|
|
@ -6,7 +6,7 @@ use Drupal\content_moderation\Entity\ContentModerationState;
|
|||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Test the ContentModerationState storage schema.
|
||||
|
@ -16,6 +16,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class ContentModerationStateStorageSchemaTest extends KernelTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -45,7 +47,7 @@ class ContentModerationStateStorageSchemaTest extends KernelTestBase {
|
|||
NodeType::create([
|
||||
'type' => 'example',
|
||||
])->save();
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->save();
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ use Drupal\KernelTests\KernelTestBase;
|
|||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
|
||||
/**
|
||||
|
@ -21,6 +22,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class ContentModerationStateTest extends KernelTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -275,7 +278,7 @@ class ContentModerationStateTest extends KernelTestBase {
|
|||
]);
|
||||
$node_type->save();
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->save();
|
||||
|
||||
|
@ -388,7 +391,7 @@ class ContentModerationStateTest extends KernelTestBase {
|
|||
'type' => 'test_type',
|
||||
])->save();
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'test_type');
|
||||
$workflow->save();
|
||||
|
||||
|
@ -415,7 +418,7 @@ class ContentModerationStateTest extends KernelTestBase {
|
|||
* Tests that entities with special languages can be moderated.
|
||||
*/
|
||||
public function testModerationWithSpecialLanguages() {
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev');
|
||||
$workflow->save();
|
||||
|
||||
|
@ -436,7 +439,7 @@ class ContentModerationStateTest extends KernelTestBase {
|
|||
* Tests that a non-translatable entity type with a langcode can be moderated.
|
||||
*/
|
||||
public function testNonTranslatableEntityTypeModeration() {
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev');
|
||||
$workflow->save();
|
||||
|
||||
|
@ -470,7 +473,7 @@ class ContentModerationStateTest extends KernelTestBase {
|
|||
// Update the entity type in order to remove the 'langcode' field.
|
||||
\Drupal::entityDefinitionUpdateManager()->applyUpdates();
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev');
|
||||
$workflow->save();
|
||||
|
||||
|
@ -500,7 +503,7 @@ class ContentModerationStateTest extends KernelTestBase {
|
|||
]);
|
||||
$node_type->save();
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
// Test both a config and non-config based bundle and entity type.
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev');
|
||||
|
@ -543,7 +546,7 @@ class ContentModerationStateTest extends KernelTestBase {
|
|||
// Create a bundle not based on any particular configuration.
|
||||
entity_test_create_bundle('test_bundle');
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test', 'test_bundle');
|
||||
$workflow->save();
|
||||
|
||||
|
@ -653,7 +656,7 @@ class ContentModerationStateTest extends KernelTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle($entity_type_id, $bundle_id);
|
||||
$workflow->save();
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use Drupal\Core\Config\ConfigImporterException;
|
|||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
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.
|
||||
|
@ -15,6 +15,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class ContentModerationWorkflowConfigTest extends KernelTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -63,7 +65,7 @@ class ContentModerationWorkflowConfigTest extends KernelTestBase {
|
|||
'type' => 'example',
|
||||
])->save();
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()
|
||||
->addState('test1', 'Test one')
|
||||
->addState('test2', 'Test two')
|
||||
|
|
|
@ -6,7 +6,7 @@ use Drupal\KernelTests\KernelTestBase;
|
|||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Tests the correct default revision is set.
|
||||
|
@ -15,6 +15,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class DefaultRevisionStateTest extends KernelTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -68,7 +70,7 @@ class DefaultRevisionStateTest extends KernelTestBase {
|
|||
|
||||
$this->container->get('content_translation.manager')->setEnabled('node', 'example', TRUE);
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->save();
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Drupal\Tests\content_moderation\Kernel;
|
|||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\content_moderation\EntityOperations
|
||||
|
@ -14,6 +14,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class EntityOperationsTest extends KernelTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -48,7 +50,7 @@ class EntityOperationsTest extends KernelTestBase {
|
|||
'label' => 'Page',
|
||||
]);
|
||||
$node_type->save();
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'page');
|
||||
$workflow->save();
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use Drupal\KernelTests\KernelTestBase;
|
|||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\node\Entity\Node;
|
||||
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
|
||||
|
@ -14,6 +14,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class EntityStateChangeValidationTest extends KernelTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -50,7 +52,7 @@ class EntityStateChangeValidationTest extends KernelTestBase {
|
|||
'type' => 'example',
|
||||
]);
|
||||
$node_type->save();
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->save();
|
||||
|
||||
|
@ -78,7 +80,7 @@ class EntityStateChangeValidationTest extends KernelTestBase {
|
|||
'type' => 'example',
|
||||
]);
|
||||
$node_type->save();
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->save();
|
||||
|
||||
|
@ -104,7 +106,7 @@ class EntityStateChangeValidationTest extends KernelTestBase {
|
|||
'type' => 'example',
|
||||
]);
|
||||
$node_type->save();
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->save();
|
||||
|
||||
|
@ -136,7 +138,7 @@ class EntityStateChangeValidationTest extends KernelTestBase {
|
|||
|
||||
// Enable moderation to test validation on existing content, with no
|
||||
// explicit state.
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addState('deleted_state', 'Deleted state');
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->save();
|
||||
|
@ -169,7 +171,7 @@ class EntityStateChangeValidationTest extends KernelTestBase {
|
|||
]);
|
||||
$node_type->save();
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->save();
|
||||
|
||||
|
@ -232,7 +234,7 @@ class EntityStateChangeValidationTest extends KernelTestBase {
|
|||
$nid = $node->id();
|
||||
|
||||
// Enable moderation for our node type.
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->save();
|
||||
|
||||
|
@ -278,7 +280,7 @@ class EntityStateChangeValidationTest extends KernelTestBase {
|
|||
$node_fr->save();
|
||||
|
||||
// Enable moderation for our node type.
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->save();
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use Drupal\entity_test\Entity\EntityTestRev;
|
|||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Tests the correct initial states are set on install.
|
||||
|
@ -15,6 +15,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class InitialStateTest extends KernelTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -66,7 +68,7 @@ class InitialStateTest extends KernelTestBase {
|
|||
$entity_test->save();
|
||||
|
||||
\Drupal::service('module_installer')->install(['content_moderation'], TRUE);
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev');
|
||||
$workflow->save();
|
||||
|
|
|
@ -6,7 +6,7 @@ use Drupal\entity_test\Entity\EntityTestMulRevPub;
|
|||
use Drupal\entity_test\Entity\EntityTestRev;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\content_moderation\ModerationInformation
|
||||
|
@ -14,6 +14,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class ModerationInformationTest extends KernelTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -48,7 +50,7 @@ class ModerationInformationTest extends KernelTestBase {
|
|||
|
||||
ConfigurableLanguage::createFromLangcode('de')->save();
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_mulrevpub', 'entity_test_mulrevpub');
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev');
|
||||
$workflow->save();
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Drupal\Tests\content_moderation\Kernel;
|
|||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList
|
||||
|
@ -14,6 +14,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class ModerationStateFieldItemListTest extends KernelTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -51,7 +53,7 @@ class ModerationStateFieldItemListTest extends KernelTestBase {
|
|||
'type' => 'example',
|
||||
]);
|
||||
$node_type->save();
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->save();
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use Drupal\Core\Form\FormState;
|
|||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\content_moderation\Plugin\Field\FieldWidget\ModerationStateWidget
|
||||
|
@ -16,6 +16,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class ModerationStateWidgetTest extends KernelTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
|
@ -46,7 +48,7 @@ class ModerationStateWidgetTest extends KernelTestBase {
|
|||
'type' => 'unmoderated',
|
||||
])->save();
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'moderated');
|
||||
$workflow->save();
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ namespace Drupal\Tests\content_moderation\Kernel;
|
|||
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
use Drupal\Tests\node\Traits\NodeCreationTrait;
|
||||
use Drupal\Tests\user\Traits\UserCreationTrait;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
|
||||
/**
|
||||
* Tests with node access enabled.
|
||||
|
@ -17,6 +17,7 @@ class NodeAccessTest extends KernelTestBase {
|
|||
|
||||
use NodeCreationTrait;
|
||||
use UserCreationTrait;
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* The moderation information service.
|
||||
|
@ -58,7 +59,7 @@ class NodeAccessTest extends KernelTestBase {
|
|||
'label' => 'Page',
|
||||
]);
|
||||
$node_type->save();
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'page');
|
||||
$workflow->save();
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Drupal\Tests\content_moderation\Kernel;
|
|||
use Drupal\Core\Render\RenderContext;
|
||||
use Drupal\entity_test\Entity\EntityTestRev;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Test the state field formatter.
|
||||
|
@ -14,6 +14,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class StateFormatterTest extends KernelTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
@ -36,7 +38,7 @@ class StateFormatterTest extends KernelTestBase {
|
|||
$this->installEntitySchema('content_moderation_state');
|
||||
$this->installConfig('content_moderation');
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev');
|
||||
$workflow->save();
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ namespace Drupal\Tests\content_moderation\Kernel;
|
|||
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Views;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
|
||||
/**
|
||||
* Tests the views integration of content_moderation.
|
||||
|
@ -15,6 +15,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class ViewsDataIntegrationTest extends ViewsKernelTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -44,7 +46,7 @@ class ViewsDataIntegrationTest extends ViewsKernelTestBase {
|
|||
'type' => 'page',
|
||||
]);
|
||||
$node_type->save();
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'page');
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_mulrevpub', 'entity_test_mulrevpub');
|
||||
$workflow->save();
|
||||
|
|
|
@ -6,6 +6,7 @@ use Drupal\entity_test\Entity\EntityTestNoBundle;
|
|||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Views;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
|
@ -19,6 +20,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class ViewsModerationStateFilterTest extends ViewsKernelTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -69,7 +72,7 @@ class ViewsModerationStateFilterTest extends ViewsKernelTestBase {
|
|||
* Tests the content moderation state filter.
|
||||
*/
|
||||
public function testStateFilterViewsRelationship() {
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->getTypePlugin()->addState('translated_draft', 'Bar');
|
||||
$configuration = $workflow->getTypePlugin()->getConfiguration();
|
||||
|
@ -156,7 +159,7 @@ class ViewsModerationStateFilterTest extends ViewsKernelTestBase {
|
|||
* Test the moderation filter with a non-translatable entity type.
|
||||
*/
|
||||
public function testNonTranslatableEntityType() {
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_no_bundle', 'entity_test_no_bundle');
|
||||
$workflow->save();
|
||||
|
||||
|
@ -182,7 +185,7 @@ class ViewsModerationStateFilterTest extends ViewsKernelTestBase {
|
|||
|
||||
// Adding a content type to the editorial workflow will enable all of the
|
||||
// editorial states.
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||
$workflow->save();
|
||||
$this->assertPluginStates([
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\content_moderation\Traits;
|
||||
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
|
||||
/**
|
||||
* Trait ContentModerationTestTraint.
|
||||
*/
|
||||
trait ContentModerationTestTrait {
|
||||
|
||||
/**
|
||||
* Creates the editorial workflow.
|
||||
*
|
||||
* @return \Drupal\workflows\Entity\Workflow
|
||||
* The editorial workflow entity.
|
||||
*/
|
||||
protected function createEditorialWorkflow() {
|
||||
$workflow = Workflow::create([
|
||||
'type' => 'content_moderation',
|
||||
'id' => 'editorial',
|
||||
'label' => 'Editorial',
|
||||
'type_settings' => [
|
||||
'states' => [
|
||||
'archived' => [
|
||||
'label' => 'Archived',
|
||||
'weight' => 5,
|
||||
'published' => FALSE,
|
||||
'default_revision' => TRUE,
|
||||
],
|
||||
'draft' => [
|
||||
'label' => 'Draft',
|
||||
'published' => FALSE,
|
||||
'default_revision' => FALSE,
|
||||
'weight' => -5,
|
||||
],
|
||||
'published' => [
|
||||
'label' => 'Published',
|
||||
'published' => TRUE,
|
||||
'default_revision' => TRUE,
|
||||
'weight' => 0,
|
||||
],
|
||||
],
|
||||
'transitions' => [
|
||||
'archive' => [
|
||||
'label' => 'Archive',
|
||||
'from' => ['published'],
|
||||
'to' => 'archived',
|
||||
'weight' => 2,
|
||||
],
|
||||
'archived_draft' => [
|
||||
'label' => 'Restore to Draft',
|
||||
'from' => ['archived'],
|
||||
'to' => 'draft',
|
||||
'weight' => 3,
|
||||
],
|
||||
'archived_published' => [
|
||||
'label' => 'Restore',
|
||||
'from' => ['archived'],
|
||||
'to' => 'published',
|
||||
'weight' => 4,
|
||||
],
|
||||
'create_new_draft' => [
|
||||
'label' => 'Create New Draft',
|
||||
'to' => 'draft',
|
||||
'weight' => 0,
|
||||
'from' => [
|
||||
'draft',
|
||||
'published',
|
||||
],
|
||||
],
|
||||
'publish' => [
|
||||
'label' => 'Publish',
|
||||
'to' => 'published',
|
||||
'weight' => 1,
|
||||
'from' => [
|
||||
'draft',
|
||||
'published',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
$workflow->save();
|
||||
return $workflow;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
namespace Drupal\Tests\content_translation\Functional;
|
||||
|
||||
use Drupal\Core\Entity\ContentEntityInterface;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
|
||||
|
||||
/**
|
||||
|
@ -11,6 +12,7 @@ use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
|
|||
abstract class ContentTranslationPendingRevisionTestBase extends ContentTranslationTestBase {
|
||||
|
||||
use ContentTypeCreationTrait;
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -110,6 +112,7 @@ abstract class ContentTranslationPendingRevisionTestBase extends ContentTranslat
|
|||
protected function setupBundle() {
|
||||
parent::setupBundle();
|
||||
$this->createContentType(['type' => $this->bundle]);
|
||||
$this->createEditorialWorkflow();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Drupal\Tests\menu_ui\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Tests Menu UI and Content Moderation integration.
|
||||
|
@ -12,6 +12,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class MenuUiContentModerationTest extends BrowserTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
|
@ -34,7 +36,7 @@ class MenuUiContentModerationTest extends BrowserTestBase {
|
|||
'display_submitted' => FALSE,
|
||||
]);
|
||||
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'page');
|
||||
$workflow->save();
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ use Drupal\migrate\Audit\AuditResult;
|
|||
use Drupal\migrate\Audit\IdAuditor;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
use Drupal\Tests\migrate_drupal\Traits\CreateTestContentEntitiesTrait;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
|
||||
/**
|
||||
* Tests the migration auditor for ID conflicts.
|
||||
|
@ -19,6 +19,7 @@ class MigrateDrupal6AuditIdsTest extends MigrateDrupal6TestBase {
|
|||
|
||||
use FileSystemModuleDiscoveryDataProviderTrait;
|
||||
use CreateTestContentEntitiesTrait;
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -44,7 +45,7 @@ class MigrateDrupal6AuditIdsTest extends MigrateDrupal6TestBase {
|
|||
$this->installEntitySchema('content_moderation_state');
|
||||
$this->installConfig('content_moderation');
|
||||
NodeType::create(['type' => 'page'])->save();
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'page');
|
||||
$workflow->save();
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ use Drupal\migrate\Audit\AuditResult;
|
|||
use Drupal\migrate\Audit\IdAuditor;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
use Drupal\Tests\migrate_drupal\Traits\CreateTestContentEntitiesTrait;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
|
||||
/**
|
||||
* Tests the migration auditor for ID conflicts.
|
||||
|
@ -19,6 +19,7 @@ class MigrateDrupal7AuditIdsTest extends MigrateDrupal7TestBase {
|
|||
|
||||
use FileSystemModuleDiscoveryDataProviderTrait;
|
||||
use CreateTestContentEntitiesTrait;
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -44,7 +45,7 @@ class MigrateDrupal7AuditIdsTest extends MigrateDrupal7TestBase {
|
|||
$this->installEntitySchema('content_moderation_state');
|
||||
$this->installConfig('content_moderation');
|
||||
NodeType::create(['type' => 'page'])->save();
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'page');
|
||||
$workflow->save();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Drupal\Tests\path\Functional;
|
|||
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Tests path aliases with Content Moderation.
|
||||
|
@ -14,6 +14,8 @@ use Drupal\workflows\Entity\Workflow;
|
|||
*/
|
||||
class PathContentModerationTest extends BrowserTestBase {
|
||||
|
||||
use ContentModerationTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
|
@ -32,7 +34,7 @@ class PathContentModerationTest extends BrowserTestBase {
|
|||
$node_type->save();
|
||||
|
||||
// Set the content type as moderated.
|
||||
$workflow = Workflow::load('editorial');
|
||||
$workflow = $this->createEditorialWorkflow();
|
||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'moderated');
|
||||
$workflow->save();
|
||||
|
||||
|
|
|
@ -197,6 +197,28 @@ class StandardTest extends BrowserTestBase {
|
|||
$this->drupalGet($url);
|
||||
$this->drupalGet($url);
|
||||
$this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'User profile page is cached by Dynamic Page Cache.');
|
||||
|
||||
// Make sure the editorial workflow is installed after enabling the
|
||||
// content_moderation module.
|
||||
\Drupal::service('module_installer')->install(['content_moderation']);
|
||||
$role = Role::create([
|
||||
'id' => 'admin_workflows',
|
||||
'label' => 'Admin workflow',
|
||||
]);
|
||||
$role->grantPermission('administer workflows');
|
||||
$role->save();
|
||||
$this->adminUser->addRole($role->id());
|
||||
$this->adminUser->save();
|
||||
$this->rebuildContainer();
|
||||
$this->drupalGet('admin/config/workflow/workflows/manage/editorial');
|
||||
$this->assertText('Draft');
|
||||
$this->assertText('Published');
|
||||
$this->assertText('Archived');
|
||||
$this->assertText('Create New Draft');
|
||||
$this->assertText('Publish');
|
||||
$this->assertText('Archive');
|
||||
$this->assertText('Restore to Draft');
|
||||
$this->assertText('Restore');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue