You are here

public function EngineTwigTest::testTwigUrlToString in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php \Drupal\Tests\system\Functional\Theme\EngineTwigTest::testTwigUrlToString()
  2. 10 core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php \Drupal\Tests\system\Functional\Theme\EngineTwigTest::testTwigUrlToString()

Tests the magic url to string Twig functions.

See also

\Drupal\Core\Url

File

core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php, line 117

Class

EngineTwigTest
Tests Twig-specific theme functionality.

Namespace

Drupal\Tests\system\Functional\Theme

Code

public function testTwigUrlToString() {
  $this
    ->drupalGet('twig-theme-test/url-to-string');
  $expected = [
    'rendered url: ' . Url::fromRoute('user.register')
      ->toString(),
  ];
  $content = $this
    ->getSession()
    ->getPage()
    ->getContent();
  $this
    ->assertFalse(empty($content), 'Page content is not empty');
  foreach ($expected as $string) {
    $this
      ->assertRaw('<div>' . $string . '</div>');
  }
}