X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fpath%2Ftests%2Fsrc%2FFunctional%2FPathContentModerationTest.php;fp=web%2Fcore%2Fmodules%2Fpath%2Ftests%2Fsrc%2FFunctional%2FPathContentModerationTest.php;h=87f117b9aac6bcfb3dc7ca7273b258dc7717dca5;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=0000000000000000000000000000000000000000;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/web/core/modules/path/tests/src/Functional/PathContentModerationTest.php b/web/core/modules/path/tests/src/Functional/PathContentModerationTest.php new file mode 100644 index 000000000..87f117b9a --- /dev/null +++ b/web/core/modules/path/tests/src/Functional/PathContentModerationTest.php @@ -0,0 +1,107 @@ + 'moderated', 'type' => 'moderated']); + $node_type->save(); + + // Set the content type as moderated. + $workflow = Workflow::load('editorial'); + $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'moderated'); + $workflow->save(); + + $this->drupalLogin($this->rootUser); + } + + /** + * Tests node path aliases on a moderated content type. + */ + public function testNodePathAlias() { + // Create some moderated content with a path alias. + $this->drupalGet('node/add/moderated'); + $this->assertSession()->fieldValueEquals('path[0][alias]', ''); + $this->drupalPostForm(NULL, [ + 'title[0][value]' => 'moderated content', + 'path[0][alias]' => '/moderated-content', + 'moderation_state[0][state]' => 'published', + ], t('Save')); + $node = $this->getNodeByTitle('moderated content'); + + // Add a pending revision with the same alias. + $this->drupalGet('node/' . $node->id() . '/edit'); + $this->assertSession()->fieldValueEquals('path[0][alias]', '/moderated-content'); + $this->drupalPostForm(NULL, [ + 'title[0][value]' => 'pending revision', + 'path[0][alias]' => '/moderated-content', + 'moderation_state[0][state]' => 'draft', + ], t('Save')); + $this->assertSession()->pageTextNotContains('You can only change the URL alias for the published version of this content.'); + + // Create some moderated content with no path alias. + $this->drupalGet('node/add/moderated'); + $this->assertSession()->fieldValueEquals('path[0][alias]', ''); + $this->drupalPostForm(NULL, [ + 'title[0][value]' => 'moderated content 2', + 'path[0][alias]' => '', + 'moderation_state[0][state]' => 'published', + ], t('Save')); + $node = $this->getNodeByTitle('moderated content 2'); + + // Add a pending revision with a new alias. + $this->drupalGet('node/' . $node->id() . '/edit'); + $this->assertSession()->fieldValueEquals('path[0][alias]', ''); + $this->drupalPostForm(NULL, [ + 'title[0][value]' => 'pending revision', + 'path[0][alias]' => '/pending-revision', + 'moderation_state[0][state]' => 'draft', + ], t('Save')); + $this->assertSession()->pageTextContains('You can only change the URL alias for the published version of this content.'); + + // Create some moderated content with no path alias. + $this->drupalGet('node/add/moderated'); + $this->assertSession()->fieldValueEquals('path[0][alias]', ''); + $this->drupalPostForm(NULL, [ + 'title[0][value]' => 'moderated content 3', + 'path[0][alias]' => '', + 'moderation_state[0][state]' => 'published', + ], t('Save')); + $node = $this->getNodeByTitle('moderated content 3'); + + // Add a pending revision with no path alias. + $this->drupalGet('node/' . $node->id() . '/edit'); + $this->assertSession()->fieldValueEquals('path[0][alias]', ''); + $this->drupalPostForm(NULL, [ + 'title[0][value]' => 'pending revision', + 'path[0][alias]' => '', + 'moderation_state[0][state]' => 'draft', + ], t('Save')); + $this->assertSession()->pageTextNotContains('You can only change the URL alias for the published version of this content.'); + } + +}