Chris@0: drupalCreateNode(); Chris@0: $this->drupalCreateNode(); Chris@0: $this->drupalCreateNode(); Chris@0: $this->drupalCreateNode(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests that the node grants cache context is auto-added, only when needed. Chris@0: * Chris@0: * @see node_query_node_access_alter() Chris@0: */ Chris@0: public function testNodeAccessCacheabilitySafeguard() { Chris@0: $this->dumpHeaders = TRUE; Chris@0: Chris@0: // The node grants cache context should be added automatically. Chris@0: $this->drupalGet(new Url('node_access_test_auto_bubbling')); Chris@0: $this->assertCacheContext('user.node_grants:view'); Chris@0: Chris@0: // The root user has the 'bypass node access' permission, which means the Chris@0: // node grants cache context is not necessary. Chris@0: $this->drupalLogin($this->rootUser); Chris@0: $this->drupalGet(new Url('node_access_test_auto_bubbling')); Chris@0: $this->assertNoCacheContext('user.node_grants:view'); Chris@0: $this->drupalLogout(); Chris@0: Chris@0: // Uninstall the module with the only hook_node_grants() implementation. Chris@0: $this->container->get('module_installer')->uninstall(['node_access_test']); Chris@0: $this->rebuildContainer(); Chris@0: Chris@0: // Because there are no node grants defined, there also is no need for the Chris@0: // node grants cache context to be bubbled. Chris@0: $this->drupalGet(new Url('node_access_test_auto_bubbling')); Chris@0: $this->assertNoCacheContext('user.node_grants:view'); Chris@0: } Chris@0: Chris@0: }