use Drupal\simpletest\ContentTypeCreationTrait;
use Drupal\Tests\BrowserTestBase;
-use Drupal\workflows\Entity\Workflow;
+use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
/**
* Test revision revert.
class ModerationRevisionRevertTest extends BrowserTestBase {
use ContentTypeCreationTrait;
+ use ContentModerationTestTrait;
/**
* Modules to enable.
$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();
+ /** @var \Drupal\Core\Routing\RouteBuilderInterface $router_builder */
+ $router_builder = $this->container->get('router.builder');
+ $router_builder->rebuildIfNeeded();
+
$admin = $this->drupalCreateUser([
'access content overview',
'administer nodes',
'bypass node access',
'view all revisions',
- 'view content moderation',
'use editorial transition create_new_draft',
'use editorial transition publish',
]);
*/
public function testEditingAfterRevertRevision() {
// Create a draft.
- $this->drupalPostForm('node/add/moderated_bundle', ['title[0][value]' => 'First draft node'], t('Save and Create New Draft'));
+ $this->drupalPostForm('node/add/moderated_bundle', [
+ 'title[0][value]' => 'First draft node',
+ 'moderation_state[0][state]' => 'draft',
+ ], t('Save'));
// Now make it published.
- $this->drupalPostForm('node/1/edit', ['title[0][value]' => 'Published node'], t('Save and Publish'));
+ $this->drupalPostForm('node/1/edit', [
+ 'title[0][value]' => 'Published node',
+ 'moderation_state[0][state]' => 'published',
+ ], t('Save'));
// Check the editing form that show the published title.
$this->drupalGet('node/1/edit');
$this->assertSession()
->pageTextContains('First draft node');
// Try to save the node.
- $this->click('.moderation-state-draft > input');
+ $this->drupalPostForm('node/1/edit', [
+ 'moderation_state[0][state]' => 'draft',
+ ], t('Save'));
// Check if the submission passed the EntityChangedConstraintValidator.
$this->assertSession()