public function EngineTwigTest::testTwigUrlGenerator in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Theme/EngineTwigTest.php \Drupal\system\Tests\Theme\EngineTwigTest::testTwigUrlGenerator()
Tests the url and url_generate Twig functions.
File
- core/
modules/ system/ src/ Tests/ Theme/ EngineTwigTest.php, line 48 - Contains \Drupal\system\Tests\Theme\EngineTwigTest.
Class
- EngineTwigTest
- Tests Twig-specific theme functionality.
Namespace
Drupal\system\Tests\ThemeCode
public function testTwigUrlGenerator() {
$this
->drupalGet('twig-theme-test/url-generator');
// Find the absolute URL of the current site.
$url_generator = $this->container
->get('url_generator');
$expected = array(
'path (as route) not absolute: ' . $url_generator
->generateFromRoute('user.register'),
'url (as route) absolute: ' . $url_generator
->generateFromRoute('user.register', array(), array(
'absolute' => TRUE,
)),
'path (as route) not absolute with fragment: ' . $url_generator
->generateFromRoute('user.register', array(), array(
'fragment' => 'bottom',
)),
'url (as route) absolute despite option: ' . $url_generator
->generateFromRoute('user.register', array(), array(
'absolute' => TRUE,
)),
'url (as route) absolute with fragment: ' . $url_generator
->generateFromRoute('user.register', array(), array(
'absolute' => TRUE,
'fragment' => 'bottom',
)),
);
// Verify that url() has the ability to bubble cacheability metadata:
// absolute URLs should bubble the 'url.site' cache context. (This only
// needs to test that cacheability metadata is bubbled *at all*; detailed
// tests for *which* cacheability metadata is bubbled live elsewhere.)
$this
->assertCacheContext('url.site');
// Make sure we got something.
$content = $this
->getRawContent();
$this
->assertFalse(empty($content), 'Page content is not empty');
foreach ($expected as $string) {
$this
->assertRaw('<div>' . $string . '</div>');
}
}