function DisplayFeedTest::testFeedFieldOutput
Same name in other branches
- 9 core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php \Drupal\Tests\views\Functional\Plugin\DisplayFeedTest::testFeedFieldOutput()
- 8.9.x core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php \Drupal\Tests\views\Functional\Plugin\DisplayFeedTest::testFeedFieldOutput()
- 10 core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php \Drupal\Tests\views\Functional\Plugin\DisplayFeedTest::testFeedFieldOutput()
Tests the rendered output for fields display.
File
-
core/
modules/ views/ tests/ src/ Functional/ Plugin/ DisplayFeedTest.php, line 122
Class
- DisplayFeedTest
- Tests the feed display plugin.
Namespace
Drupal\Tests\views\Functional\PluginCode
public function testFeedFieldOutput() : void {
$this->drupalCreateContentType([
'type' => 'page',
]);
// Verify a title with HTML entities is properly escaped.
$node_title = 'This "cool" & "neat" article\'s title';
$node = $this->drupalCreateNode([
'title' => $node_title,
'body' => [
0 => [
'value' => 'A paragraph',
'format' => filter_default_format(),
],
],
]);
// Create an alias to verify that outbound processing runs on the link and
// ensure that the node actually contains that.
$this->createPathAlias('/node/' . $node->id(), '/the-article-alias');
$node_link = $node->toUrl()
->setAbsolute()
->toString();
$this->assertStringContainsString('/the-article-alias', $node_link);
$this->drupalGet('test-feed-display-fields.xml');
$this->assertEquals($node_title, $this->getSession()
->getDriver()
->getText('//item/title'));
$this->assertEquals($node_link, $this->getSession()
->getDriver()
->getText('//item/link'));
// HTML should no longer be escaped since it is CDATA. Confirm it is wrapped
// in CDATA.
$this->assertSession()
->responseContains('<description><![CDATA[');
// Confirm that the view is still displaying the content.
$this->assertSession()
->responseContains('<p>A paragraph</p>');
// Confirm that the CDATA is closed properly.
$this->assertSession()
->responseContains(']]></description>');
// Change the display to use the nid field, which is rewriting output as
// 'node/{{ nid }}' and make sure things are still working.
$view = Views::getView('test_display_feed');
$display =& $view->storage
->getDisplay('feed_2');
$display['display_options']['row']['options']['link_field'] = 'nid';
$view->save();
$this->drupalGet('test-feed-display-fields.xml');
$this->assertEquals($node_title, $this->getSession()
->getDriver()
->getText('//item/title'));
$this->assertEquals($node_link, $this->getSession()
->getDriver()
->getText('//item/link'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.