comparison core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
139 // Verify visibility rules. 139 // Verify visibility rules.
140 $this->drupalGet(''); 140 $this->drupalGet('');
141 $label = $block->label(); 141 $label = $block->label();
142 $this->assertNoText($label, 'Block was not displayed on the front page.'); 142 $this->assertNoText($label, 'Block was not displayed on the front page.');
143 $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user', 'route']); 143 $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user', 'route']);
144
145 // Ensure that a page that does not have a node context can still be cached,
146 // the front page is the user page which is already cached from the login
147 // request above.
148 $this->assertSame('HIT', $this->getSession()->getResponseHeader('X-Drupal-Dynamic-Cache'));
149
144 $this->drupalGet('node/add/article'); 150 $this->drupalGet('node/add/article');
145 $this->assertText($label, 'Block was displayed on the node/add/article page.'); 151 $this->assertText($label, 'Block was displayed on the node/add/article page.');
146 $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'session', 'theme', 'url.path', 'url.query_args', 'user', 'route']); 152 $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'session', 'theme', 'url.path', 'url.query_args', 'user', 'route']);
153
154 // The node/add/article page is an admin path and currently uncacheable.
155 $this->assertSame('UNCACHEABLE', $this->getSession()->getResponseHeader('X-Drupal-Dynamic-Cache'));
156
147 $this->drupalGet('node/' . $node1->id()); 157 $this->drupalGet('node/' . $node1->id());
148 $this->assertText($label, 'Block was displayed on the node/N when node is of type article.'); 158 $this->assertText($label, 'Block was displayed on the node/N when node is of type article.');
149 $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user', 'route', 'timezone']); 159 $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user', 'route', 'timezone']);
160 $this->assertSame('MISS', $this->getSession()->getResponseHeader('X-Drupal-Dynamic-Cache'));
161 $this->drupalGet('node/' . $node1->id());
162 $this->assertSame('HIT', $this->getSession()->getResponseHeader('X-Drupal-Dynamic-Cache'));
163
150 $this->drupalGet('node/' . $node5->id()); 164 $this->drupalGet('node/' . $node5->id());
151 $this->assertNoText($label, 'Block was not displayed on nodes of type page.'); 165 $this->assertNoText($label, 'Block was not displayed on nodes of type page.');
152 $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user', 'route', 'timezone']); 166 $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user', 'route', 'timezone']);
167 $this->assertSame('MISS', $this->getSession()->getResponseHeader('X-Drupal-Dynamic-Cache'));
168 $this->drupalGet('node/' . $node5->id());
169 $this->assertSame('HIT', $this->getSession()->getResponseHeader('X-Drupal-Dynamic-Cache'));
153 170
154 $this->drupalLogin($this->adminUser); 171 $this->drupalLogin($this->adminUser);
155 $this->drupalGet('admin/structure/block'); 172 $this->drupalGet('admin/structure/block');
156 $this->assertText($label, 'Block was displayed on the admin/structure/block page.'); 173 $this->assertText($label, 'Block was displayed on the admin/structure/block page.');
157 $this->assertLinkByHref($block->url()); 174 $this->assertLinkByHref($block->url());