Loading core/modules/node/node.services.yml +1 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ services: public: false tags: - { name: page_cache_response_policy } - { name: dynamic_page_cache_response_policy } cache_context.user.node_grants: class: Drupal\node\Cache\NodeAccessGrantsCacheContext arguments: ['@current_user'] Loading core/modules/node/tests/src/Functional/PagePreviewTest.php +24 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ use Drupal\taxonomy\Entity\Vocabulary; use Drupal\Tests\field\Traits\EntityReferenceTestTrait; use Drupal\Tests\TestFileCreationTrait; use Drupal\user\RoleInterface; /** * Tests the node entity preview functionality. Loading Loading @@ -500,4 +501,27 @@ public function testSimultaneousPreview() { $this->assertText($edit2[$title_key]); } /** * Tests node preview with dynamic_page_cache and anonymous users. */ 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(t('Back to content editing')); $edit = [ $title_key => $this->randomMachineName(8), ]; $this->submitForm($edit, 'Preview'); $this->assertSession()->pageTextContains($edit[$title_key]); } } Loading
core/modules/node/node.services.yml +1 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ services: public: false tags: - { name: page_cache_response_policy } - { name: dynamic_page_cache_response_policy } cache_context.user.node_grants: class: Drupal\node\Cache\NodeAccessGrantsCacheContext arguments: ['@current_user'] Loading
core/modules/node/tests/src/Functional/PagePreviewTest.php +24 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ use Drupal\taxonomy\Entity\Vocabulary; use Drupal\Tests\field\Traits\EntityReferenceTestTrait; use Drupal\Tests\TestFileCreationTrait; use Drupal\user\RoleInterface; /** * Tests the node entity preview functionality. Loading Loading @@ -500,4 +501,27 @@ public function testSimultaneousPreview() { $this->assertText($edit2[$title_key]); } /** * Tests node preview with dynamic_page_cache and anonymous users. */ 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(t('Back to content editing')); $edit = [ $title_key => $this->randomMachineName(8), ]; $this->submitForm($edit, 'Preview'); $this->assertSession()->pageTextContains($edit[$title_key]); } }