commit c45b5c07c887420e7387725056ae6c1feedfca50 Author: Joel Pittet Date: Sat Feb 8 21:20:26 2014 -0800 xpath to the rescue 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 d6bfa7d..22e88a0 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/RenderElementTypesTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/RenderElementTypesTest.php @@ -125,7 +125,17 @@ function testMoreLink() { '#type' => 'more_link', '#href' => 'admin/content', ), - 'expected' => 'More', + 'expected' => '//a[@href="/admin/content" 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( + '#type' => 'more_link', + '#href' => '', + '#title' => 'More Titles', + ), + 'expected' => '//a[@href="/" and @class="more-link" and text()="More Titles"]', ), // Test more_link anchor tag generation without class attributes to test additional classes. array( @@ -134,14 +144,19 @@ function testMoreLink() { '#type' => 'more_link', '#href' => 'admin/content', '#attributes' => array( - 'name' => 'description', + 'title' => 'description', 'class' => array('drupal', 'test'), ), ), - 'expected' => 'More', + 'expected' => '//a[@href="/admin/content" and @title="description" and contains(@class, "more-link") and contains(@class, "drupal") and contains(@class, "test") and text()="More"]', ), ); - $this->assertElements($elements); + + foreach($elements as $element) { + $xml = new \SimpleXMLElement(drupal_render($element['value'])); + $result = $xml->xpath($element['expected']); + $this->assertTrue($result, '"' . $element['name'] . '" input rendered correctly by drupal_render().'); + } } }