commit 1122a1eafd51478c0412bd589cedbcdedad9a6c9 Author: Joel Pittet Date: Sun Feb 23 15:48:25 2014 -0800 routes, home, path and absolute. diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/RenderElementTypesTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/RenderElementTypesTest.php index e851ab2..2f77c98 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/RenderElementTypesTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/RenderElementTypesTest.php @@ -24,7 +24,7 @@ class RenderElementTypesTest extends DrupalUnitTestBase { * * @var array */ - public static $modules = array('system'); + public static $modules = array('system', 'router_test'); public static function getInfo() { return array( @@ -37,6 +37,8 @@ public static function getInfo() { protected function setUp() { parent::setUp(); $this->installConfig(array('system')); + $this->installSchema('system', array('router')); + \Drupal::service('router.builder')->rebuild(); $this->container->get('theme_handler')->enable(array('stark')); } @@ -271,7 +273,6 @@ function testMaintenancePage() { */ function testMoreLink() { $elements = array( - // Test more_link anchor tag generation without class attributes to test default. array( 'name' => "#type 'more_link' anchor tag generation without extra classes", 'value' => array( @@ -280,7 +281,6 @@ function testMoreLink() { ), 'expected' => '//a[@href="http://drupal.org" and @class="more-link" and text()="More"]', ), - // Test more_link anchor tag generation with title change. array( 'name' => "#type 'more_link' anchor tag generation with different link text", 'value' => array( @@ -290,7 +290,6 @@ function testMoreLink() { ), 'expected' => '//a[@href="http://drupal.org" and @class="more-link" and text()="More Titles"]', ), - // Test more_link anchor tag generation without class attributes to test additional classes. array( 'name' => "#type 'more_link' anchor tag generation with extra classes", 'value' => array( @@ -303,6 +302,40 @@ function testMoreLink() { ), 'expected' => '//a[@href="http://drupal.org" and @title="description" and contains(@class, "more-link") and contains(@class, "drupal") and contains(@class, "test") and text()="More"]', ), + array( + 'name' => "#type 'more_link' anchor tag with a relative path", + 'value' => array( + '#type' => 'more_link', + '#href' => 'a/link', + ), + 'expected' => '//a[@href="' . url('a/link') . '" and @class="more-link" and text()="More"]', + ), + array( + 'name' => "#type 'more_link' anchor tag with a route", + 'value' => array( + '#type' => 'more_link', + '#route_name' => 'router_test.1', + '#route_parameters' => array(), + ), + 'expected' => '//a[@href="' . \Drupal::urlGenerator()->generate('router_test.1') . '" and @class="more-link" and text()="More"]', + ), + array( + 'name' => "#type 'more_link' anchor tag with an absolute path", + 'value' => array( + '#type' => 'more_link', + '#href' => 'admin/content', + '#options' => array('absolute' => TRUE), + ), + 'expected' => '//a[@href="' . url('admin/content', array('absolute' => TRUE)) . '" and @class="more-link" and text()="More"]', + ), + array( + 'name' => "#type 'more_link' anchor tag to the front page", + 'value' => array( + '#type' => 'more_link', + '#href' => '', + ), + 'expected' => '//a[@href="' . url('') . '" and @class="more-link" and text()="More"]', + ), ); foreach($elements as $element) {