public function PagePreviewTest::testPagePreviewCache in Drupal 9
Tests node preview with dynamic_page_cache and anonymous users.
File
- core/
modules/ node/ tests/ src/ Functional/ PagePreviewTest.php, line 521
Class
- PagePreviewTest
- Tests the node entity preview functionality.
Namespace
Drupal\Tests\node\FunctionalCode
public function testPagePreviewCache() {
\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]);
}