function DrupalAddHtmlHeadLinkTest::testDrupalAddHtmlHeadLink

Tests drupal_add_html_head_link().

File

modules/simpletest/tests/common.test, line 3414

Class

DrupalAddHtmlHeadLinkTest
Test for drupal_add_html_head_link().

Code

function testDrupalAddHtmlHeadLink() {
    $this->drupalGet('common-test/html_head_link');
    $expected_link_header = implode(',', array(
        '</foo?bar=baz>; rel="alternate"',
        '</foo/bar>; hreflang="nl"; rel="alternate"',
        '</foo/bar>; hreflang="de"; rel="alternate"',
        '</foo?bar=baz&baz=false>; hreflang="en"; rel="alternate"',
    ));
    $this->assertEqual($this->drupalGetHeader('Link'), $expected_link_header);
    // Check that duplicate alternate URLs with different hreflangs are allowed.
    $test_link = $this->xpath('//head/link[@rel="alternate"][@href="/foo/bar"]');
    $this->assertEqual(count($test_link), 2, 'Duplicate alternate URLs are allowed.');
    // Check that link element attributes are HTML-encoded.
    $this->assertRaw('<link href="/foo?bar=baz&amp;baz=false" hreflang="en" rel="alternate" />');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.