diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php index 61805768f7..7aab0d46c3 100644 --- a/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php +++ b/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php @@ -247,13 +247,19 @@ public function testContentTranslationNodeForm() { 'title[0][value]' => 'Some moderated content', 'body[0][value]' => 'First version of the content.', ], t('Save and Create New Draft')); + $this->assertTrue($this->xpath('//ul[@class="entity-moderation-form"]')); $node = $this->drupalGetNodeByTitle('Some moderated content'); $this->assertTrue($node->language(), 'en'); $edit_path = sprintf('node/%d/edit', $node->id()); $translate_path = sprintf('node/%d/translations/add/en/fr', $node->id()); + $latest_version_path = sprintf('node/%d/latest', $node->id()); $french = \Drupal::languageManager()->getLanguage('fr'); + $this->drupalGet($latest_version_path); + $this->assertSession()->statusCodeEquals('403'); + $this->assertFalse($this->xpath('//ul[@class="entity-moderation-form"]')); + // Add french translation (revision 2). $this->drupalGet($translate_path); $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); @@ -263,6 +269,10 @@ public function testContentTranslationNodeForm() { 'body[0][value]' => 'Second version of the content.', ], t('Save and Publish (this translation)')); + $this->drupalGet($latest_version_path, ['language' => $french]); + $this->assertSession()->statusCodeEquals('403'); + $this->assertFalse($this->xpath('//ul[@class="entity-moderation-form"]')); + // Add french forward revision (revision 3). $this->drupalGet($edit_path, ['language' => $french]); $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); @@ -272,6 +282,9 @@ public function testContentTranslationNodeForm() { 'body[0][value]' => 'Third version of the content.', ], t('Save and Create New Draft (this translation)')); + $this->drupalGet($latest_version_path, ['language' => $french]); + $this->assertTrue($this->xpath('//ul[@class="entity-moderation-form"]')); + // It should not be possible to add a new english revision. $this->drupalGet($edit_path); $this->assertFalse($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); @@ -279,6 +292,16 @@ public function testContentTranslationNodeForm() { $this->assertFalse($this->xpath('//input[@value="Save and Archive (this translation)"]')); $this->assertSession()->pageTextContains('Unable to save this Moderated content.'); + $this->clickLink('Publish'); + $this->assertSession()->fieldValueEquals('body[0][value]', 'Third version of the content.'); + + $this->drupalGet($edit_path); + $this->clickLink('Delete'); + $this->assertSession()->buttonExists('Delete'); + + $this->drupalGet($latest_version_path); + $this->assertFalse($this->xpath('//ul[@class="entity-moderation-form"]')); + // Publish the french forward revision (revision 4). $this->drupalGet($edit_path, ['language' => $french]); $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); @@ -288,6 +311,9 @@ public function testContentTranslationNodeForm() { 'body[0][value]' => 'Fifth version of the content.', ], t('Save and Publish (this translation)')); + $this->drupalGet($latest_version_path, ['language' => $french]); + $this->assertFalse($this->xpath('//ul[@class="entity-moderation-form"]')); + // Now we can publish the english (revision 5). $this->drupalGet($edit_path); $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); @@ -297,6 +323,9 @@ public function testContentTranslationNodeForm() { 'body[0][value]' => 'Sixth version of the content.', ], t('Save and Publish (this translation)')); + $this->drupalGet($latest_version_path); + $this->assertFalse($this->xpath('//ul[@class="entity-moderation-form"]')); + // Make sure we're allowed to create a forward french revision. $this->drupalGet($edit_path, ['language' => $french]); $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); @@ -312,6 +341,9 @@ public function testContentTranslationNodeForm() { 'body[0][value]' => 'Seventh version of the content.', ], t('Save and Create New Draft (this translation)')); + $this->drupalGet($latest_version_path); + $this->assertTrue($this->xpath('//ul[@class="entity-moderation-form"]')); + // Make sure we're not allowed to create a forward french revision. $this->drupalGet($edit_path, ['language' => $french]); $this->assertFalse($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); @@ -319,6 +351,9 @@ public function testContentTranslationNodeForm() { $this->assertFalse($this->xpath('//input[@value="Save and Archive (this translation)"]')); $this->assertSession()->pageTextContains('Unable to save this Moderated content.'); + $this->drupalGet($latest_version_path, ['language' => $french]); + $this->assertFalse($this->xpath('//ul[@class="entity-moderation-form"]')); + // We should be able to publish the english forward revision (revision 7) $this->drupalGet($edit_path); $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); @@ -328,6 +363,9 @@ public function testContentTranslationNodeForm() { 'body[0][value]' => 'Eighth version of the content.', ], t('Save and Publish (this translation)')); + $this->drupalGet($latest_version_path); + $this->assertFalse($this->xpath('//ul[@class="entity-moderation-form"]')); + // Make sure we're allowed to create a forward french revision. $this->drupalGet($edit_path, ['language' => $french]); $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]'));