function NodeRssCacheTest::testNodeRssCacheContent
Same name in other branches
- 10 core/modules/node/tests/src/Functional/NodeRssCacheTest.php \Drupal\Tests\node\Functional\NodeRssCacheTest::testNodeRssCacheContent()
Ensure the RSS teaser render does not interfere with default theme cache.
File
-
core/
modules/ node/ tests/ src/ Functional/ NodeRssCacheTest.php, line 57
Class
- NodeRssCacheTest
- Ensures that RSS render cache doesn't interfere with other caches.
Namespace
Drupal\Tests\node\FunctionalCode
public function testNodeRssCacheContent() : void {
// Only the plain_text text format is available by default, which escapes
// all HTML.
FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
'filters' => [],
])->save();
// Create the test node.
$node = $this->drupalCreateNode([
'type' => 'article',
'promote' => 1,
'title' => 'Article Test Title',
'body' => [
'value' => '<p>Article test text.</p>',
'format' => 'full_html',
],
]);
// Render the node in the RSS feed view as a teaser.
$this->drupalGet('test-node-article-feed');
// Render the teaser normally.
$viewBuilder = $this->container
->get('entity_type.manager')
->getViewBuilder('node');
$build = $viewBuilder->view($node, 'teaser');
$output = $this->container
->get('renderer')
->renderInIsolation($build);
// Teaser must contain an "<article" tag from the stable9 theme.
$this->assertStringContainsString('<article', (string) $output);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.