X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fnode%2Ftests%2Fsrc%2FFunctional%2FNodePreviewAnonymousTest.php;fp=web%2Fcore%2Fmodules%2Fnode%2Ftests%2Fsrc%2FFunctional%2FNodePreviewAnonymousTest.php;h=f10d8b7389d66d1b2008376a2f38186d2d1aeb8d;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/node/tests/src/Functional/NodePreviewAnonymousTest.php b/web/core/modules/node/tests/src/Functional/NodePreviewAnonymousTest.php new file mode 100644 index 000000000..f10d8b738 --- /dev/null +++ b/web/core/modules/node/tests/src/Functional/NodePreviewAnonymousTest.php @@ -0,0 +1,62 @@ +drupalCreateContentType([ + 'type' => 'page', + 'name' => 'Basic page', + 'display_submitted' => FALSE, + ]); + + // Grant create and editing permissions to anonymous user: + $anonymous_role = Role::load(AccountInterface::ANONYMOUS_ROLE); + $anonymous_role->grantPermission('create page content'); + $anonymous_role->save(); + } + + /** + * Checks the node preview functionality for anonymous users. + */ + public function testAnonymousPagePreview() { + + $title_key = 'title[0][value]'; + $body_key = 'body[0][value]'; + + // Fill in node creation form and preview node. + $edit = [ + $title_key => $this->randomMachineName(), + $body_key => $this->randomMachineName(), + ]; + $this->drupalPostForm('node/add/page', $edit, t('Preview')); + + // Check that the preview is displaying the title, body and term. + $this->assertSession()->linkExists(t('Back to content editing')); + $this->assertSession()->responseContains($edit[$body_key]); + $this->assertSession()->titleEquals($edit[$title_key] . ' | Drupal'); + } + +}