diff --git a/core/modules/content_moderation/src/Tests/ModerationFormTest.php b/core/modules/content_moderation/src/Tests/ModerationFormTest.php index 74a5a5bc5e..6a5b3a3ddc 100644 --- a/core/modules/content_moderation/src/Tests/ModerationFormTest.php +++ b/core/modules/content_moderation/src/Tests/ModerationFormTest.php @@ -138,7 +138,7 @@ public function testContentTranslationNodeForm() { // environment so that multilingual services are used. $this->rebuildContainer(); - // Create new moderated content in draft. + // Create new moderated content in draft (revision 1). $this->drupalPostForm('node/add/moderated_content', [ 'title[0][value]' => 'Some moderated content', 'body[0][value]' => 'First version of the content.', @@ -149,7 +149,7 @@ public function testContentTranslationNodeForm() { $edit_path = sprintf('node/%d/edit', $node->id()); $translate_path = sprintf('node/%d/translations/add/en/fr', $node->id()); - // Add french translation. + // Add french translation (revision 2). $this->drupalGet($translate_path); $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); $this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]')); @@ -158,7 +158,7 @@ public function testContentTranslationNodeForm() { 'body[0][value]' => 'Second version of the content.', ], t('Save and Publish (this translation)')); - // Add french forward revision. + // Add french forward revision (revision 3). $this->drupalGet('fr/' . $edit_path); $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); $this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]')); @@ -167,7 +167,7 @@ public function testContentTranslationNodeForm() { 'body[0][value]' => 'Third version of the content.', ], t('Save and Create New Draft (this translation)')); - // Add another english revision. + // Add another english revision (revision 4). $this->drupalGet($edit_path); $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); $this->assertFalse($this->xpath('//input[@value="Save and Publish (this translation)"]')); @@ -177,7 +177,14 @@ public function testContentTranslationNodeForm() { 'body[0][value]' => 'Forth version of the content.', ], t('Save and Create New Draft (this translation)')); - // Publish the french forward revision + // It should still only be possible to create draft revisions. + $this->drupalGet($edit_path); + $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); + $this->assertFalse($this->xpath('//input[@value="Save and Publish (this translation)"]')); + $this->assertFalse($this->xpath('//input[@value="Save and Archive (this translation)"]')); + $this->assertText('It is not possible to Publish this Content.'); + + // Publish the french forward revision (revision 5). $this->drupalGet('fr/' . $edit_path); $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); $this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]')); @@ -186,7 +193,7 @@ public function testContentTranslationNodeForm() { 'body[0][value]' => 'Fifth version of the content.', ], t('Save and Publish (this translation)')); - // Now we can publish the english. + // Now we can publish the english (revision 6). $this->drupalGet($edit_path); $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); $this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]')); @@ -201,7 +208,7 @@ public function testContentTranslationNodeForm() { $this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]')); $this->assertTrue($this->xpath('//input[@value="Save and Archive (this translation)"]')); - // Add a english forward revision. + // Add a english forward revision (revision 7). $this->drupalGet($edit_path); $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); $this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]')); @@ -217,7 +224,8 @@ public function testContentTranslationNodeForm() { $this->assertFalse($this->xpath('//input[@value="Save and Archive (this translation)"]')); $this->assertText('It is not possible to Create New Draft, Publish, Archive this Content.'); - // We should be able to publish the english forward revision. + // We should be able to publish the english forward revision (revision 8)usa12pop + //. $this->drupalGet($edit_path); $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); $this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]')); @@ -238,6 +246,32 @@ public function testContentTranslationNodeForm() { $this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]')); $this->assertTrue($this->xpath('//input[@value="Save and Archive (this translation)"]')); + // Create new moderated content in draft (revision 1). + $this->drupalPostForm('node/add/moderated_content', [ + 'title[0][value]' => 'Second moderated content', + 'body[0][value]' => 'First version of the content.', + ], t('Save and Publish')); + + $node = $this->drupalGetNodeByTitle('Second 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()); + + // Add a forward revision (revision 2). + $this->drupalGet($edit_path); + $this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); + $this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]')); + $this->assertTrue($this->xpath('//input[@value="Save and Archive (this translation)"]')); + $this->drupalPostForm(NULL, [ + 'body[0][value]' => 'Second version of the content.', + ], t('Save and Create New Draft (this translation)')); + + // It shouldn't be possible to translate as we have a forward revision. + $this->drupalGet($translate_path); + $this->assertFalse($this->xpath('//input[@value="Save and Create New Draft (this translation)"]')); + $this->assertFalse($this->xpath('//input[@value="Save and Publish (this translation)"]')); + $this->assertFalse($this->xpath('//input[@value="Save and Archive (this translation)"]')); + $this->assertText('It is not possible to Create New Draft, Publish, Archive this Content.'); } }