$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
);
}