function DisplayFeedTest::testDisabledFeed
Same name in other branches
- 8.9.x core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php \Drupal\Tests\views\Functional\Plugin\DisplayFeedTest::testDisabledFeed()
- 10 core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php \Drupal\Tests\views\Functional\Plugin\DisplayFeedTest::testDisabledFeed()
- 11.x core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php \Drupal\Tests\views\Functional\Plugin\DisplayFeedTest::testDisabledFeed()
Tests that nothing is output when the feed display is disabled.
File
-
core/
modules/ views/ tests/ src/ Functional/ Plugin/ DisplayFeedTest.php, line 159
Class
- DisplayFeedTest
- Tests the feed display plugin.
Namespace
Drupal\Tests\views\Functional\PluginCode
public function testDisabledFeed() {
$this->drupalCreateContentType([
'type' => 'page',
]);
$this->drupalCreateNode();
// Ensure that the feed_1 display is attached to the page_1 display.
$view = Views::getView('test_attached_disabled');
$view->setDisplay('page_1');
$attached_displays = $view->display_handler
->getAttachedDisplays();
$this->assertContains('feed_1', $attached_displays, 'The feed display is attached to the page display.');
// Check that the rss header is output on the page display.
$this->drupalGet('/test-attached-disabled');
$this->assertSession()
->elementAttributeContains('xpath', '//link[@rel="alternate"]', 'type', 'application/rss+xml');
$this->assertSession()
->elementAttributeContains('xpath', '//link[@rel="alternate"]', 'href', 'test-attached-disabled.xml');
// Disable the feed display.
$view->displayHandlers
->get('feed_1')
->setOption('enabled', FALSE);
$view->save();
// Ensure there is no link rel present on the page.
$this->drupalGet('/test-attached-disabled');
$this->assertSession()
->elementNotExists('xpath', '//link[@rel="alternate"]');
// Ensure the feed attachment returns 'Not found'.
$this->drupalGet('/test-attached-disabled.xml');
$this->assertSession()
->statusCodeEquals(404);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.