function PagePreviewTest::testPagePreviewCache

Same name and namespace in other branches
  1. 9 core/modules/node/tests/src/Functional/PagePreviewTest.php \Drupal\Tests\node\Functional\PagePreviewTest::testPagePreviewCache()
  2. 10 core/modules/node/tests/src/Functional/PagePreviewTest.php \Drupal\Tests\node\Functional\PagePreviewTest::testPagePreviewCache()

Tests node preview with dynamic_page_cache and anonymous users.

File

core/modules/node/tests/src/Functional/PagePreviewTest.php, line 532

Class

PagePreviewTest
Tests the node entity preview functionality.

Namespace

Drupal\Tests\node\Functional

Code

public function testPagePreviewCache() : void {
    \Drupal::service('module_installer')->uninstall([
        'node_test',
    ]);
    $this->drupalLogout();
    $title_key = 'title[0][value]';
    user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [
        'create page content',
        'access content',
    ]);
    $edit = [
        $title_key => $this->randomMachineName(8),
    ];
    $this->drupalGet('/node/add/page');
    $this->submitForm($edit, 'Preview');
    $this->assertSession()
        ->pageTextContains($edit[$title_key]);
    $this->clickLink('Back to content editing');
    $edit = [
        $title_key => $this->randomMachineName(8),
    ];
    $this->submitForm($edit, 'Preview');
    $this->assertSession()
        ->pageTextContains($edit[$title_key]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.