Tests for active class in l() function.
function testLActiveClass() {
$path = 'common-test/l-active-class';
$options = array();
$this
->drupalGet($path, $options);
$links = $this
->xpath('//a[@href = :href and contains(@class, :class)]', array(
':href' => url($path, $options),
':class' => 'active',
));
$this
->assertTrue(isset($links[0]), 'A link to the current page is marked active.');
$options = array(
'query' => array(
'foo' => 'bar',
),
);
$links = $this
->xpath('//a[@href = :href and not(contains(@class, :class))]', array(
':href' => url($path, $options),
':class' => 'active',
));
$this
->assertTrue(isset($links[0]), 'A link to the current page with a query string when the current page has no query string is not marked active.');
$this
->drupalGet($path, $options);
$links = $this
->xpath('//a[@href = :href and contains(@class, :class)]', array(
':href' => url($path, $options),
':class' => 'active',
));
$this
->assertTrue(isset($links[0]), 'A link to the current page with a query string that matches the current query string is marked active.');
$options = array();
$links = $this
->xpath('//a[@href = :href and not(contains(@class, :class))]', array(
':href' => url($path, $options),
':class' => 'active',
));
$this
->assertTrue(isset($links[0]), 'A link to the current page without a query string when the current page has a query string is not marked active.');
}