Chris@16: drupalCreateContentType([ Chris@16: 'type' => 'page', Chris@16: 'name' => 'Basic page', Chris@16: 'display_submitted' => FALSE, Chris@16: ]); Chris@16: Chris@16: // Grant create and editing permissions to anonymous user: Chris@16: $anonymous_role = Role::load(AccountInterface::ANONYMOUS_ROLE); Chris@16: $anonymous_role->grantPermission('create page content'); Chris@16: $anonymous_role->save(); Chris@16: } Chris@16: Chris@16: /** Chris@16: * Checks the node preview functionality for anonymous users. Chris@16: */ Chris@16: public function testAnonymousPagePreview() { Chris@16: Chris@16: $title_key = 'title[0][value]'; Chris@16: $body_key = 'body[0][value]'; Chris@16: Chris@16: // Fill in node creation form and preview node. Chris@16: $edit = [ Chris@16: $title_key => $this->randomMachineName(), Chris@17: $body_key => $this->randomMachineName(), Chris@16: ]; Chris@16: $this->drupalPostForm('node/add/page', $edit, t('Preview')); Chris@16: Chris@16: // Check that the preview is displaying the title, body and term. Chris@16: $this->assertSession()->linkExists(t('Back to content editing')); Chris@16: $this->assertSession()->responseContains($edit[$body_key]); Chris@16: $this->assertSession()->titleEquals($edit[$title_key] . ' | Drupal'); Chris@16: } Chris@16: Chris@16: }