X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcontent_moderation%2Ftests%2Fsrc%2FFunctional%2FModerationRevisionRevertTest.php;h=b1ad72045a0c057c1b6144eb4c032448262350f3;hb=4f1b9b4ab48a8498afac9e2213a02a23ccf4a06c;hp=7dac15667fbdd5627371837e3fe17c25a26e6bb2;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/content_moderation/tests/src/Functional/ModerationRevisionRevertTest.php b/web/core/modules/content_moderation/tests/src/Functional/ModerationRevisionRevertTest.php index 7dac15667..b1ad72045 100644 --- a/web/core/modules/content_moderation/tests/src/Functional/ModerationRevisionRevertTest.php +++ b/web/core/modules/content_moderation/tests/src/Functional/ModerationRevisionRevertTest.php @@ -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,16 +35,19 @@ 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(); + /** @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', ]); @@ -55,10 +59,16 @@ class ModerationRevisionRevertTest extends BrowserTestBase { */ 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'); @@ -76,7 +86,9 @@ class ModerationRevisionRevertTest extends BrowserTestBase { $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()