function AddFeedTest::testBasicFeedAddNoTitle
Same name in other branches
- 9 core/modules/system/tests/src/Kernel/Common/AddFeedTest.php \Drupal\Tests\system\Kernel\Common\AddFeedTest::testBasicFeedAddNoTitle()
- 8.9.x core/modules/system/tests/src/Kernel/Common/AddFeedTest.php \Drupal\Tests\system\Kernel\Common\AddFeedTest::testBasicFeedAddNoTitle()
- 11.x core/modules/system/tests/src/Kernel/Common/AddFeedTest.php \Drupal\Tests\system\Kernel\Common\AddFeedTest::testBasicFeedAddNoTitle()
Tests attaching feeds with paths, URLs, and titles.
File
-
core/
modules/ system/ tests/ src/ Kernel/ Common/ AddFeedTest.php, line 25
Class
- AddFeedTest
- Make sure that attaching feeds works correctly with various constructs.
Namespace
Drupal\Tests\system\Kernel\CommonCode
public function testBasicFeedAddNoTitle() : void {
$path = $this->randomMachineName(12);
$external_url = 'http://' . $this->randomMachineName(12) . '/' . $this->randomMachineName(12);
$fully_qualified_local_url = Url::fromUri('base:' . $this->randomMachineName(12), [
'absolute' => TRUE,
])
->toString();
$path_for_title = $this->randomMachineName(12);
$external_for_title = 'http://' . $this->randomMachineName(12) . '/' . $this->randomMachineName(12);
$fully_qualified_for_title = Url::fromUri('base:' . $this->randomMachineName(12), [
'absolute' => TRUE,
])
->toString();
$urls = [
'path without title' => [
'url' => Url::fromUri('base:' . $path, [
'absolute' => TRUE,
])->toString(),
'title' => '',
],
'external URL without title' => [
'url' => $external_url,
'title' => '',
],
'local URL without title' => [
'url' => $fully_qualified_local_url,
'title' => '',
],
'path with title' => [
'url' => Url::fromUri('base:' . $path_for_title, [
'absolute' => TRUE,
])->toString(),
'title' => $this->randomMachineName(12),
],
'external URL with title' => [
'url' => $external_for_title,
'title' => $this->randomMachineName(12),
],
'local URL with title' => [
'url' => $fully_qualified_for_title,
'title' => $this->randomMachineName(12),
],
];
$build = [];
foreach ($urls as $feed_info) {
$build['#attached']['feed'][] = [
$feed_info['url'],
$feed_info['title'],
];
}
// Use the bare HTML page renderer to render our links.
$renderer = $this->container
->get('bare_html_page_renderer');
$response = $renderer->renderBarePage($build, '', 'maintenance_page');
// Glean the content from the response object.
$this->setRawContent($response->getContent());
// Assert that the content contains the RSS links we specified.
foreach ($urls as $description => $feed_info) {
$this->assertPattern($this->urlToRSSLinkPattern($feed_info['url'], $feed_info['title']));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.