protected function LocalActionTest::assertLocalAction in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Menu/LocalActionTest.php \Drupal\system\Tests\Menu\LocalActionTest::assertLocalAction()
Asserts local actions in the page output.
Parameters
array $actions: A list of expected action link titles, keyed by the hrefs.
1 call to LocalActionTest::assertLocalAction()
- LocalActionTest::testLocalAction in core/
modules/ system/ src/ Tests/ Menu/ LocalActionTest.php - Tests appearance of local actions.
File
- core/
modules/ system/ src/ Tests/ Menu/ LocalActionTest.php, line 59 - Contains \Drupal\system\Tests\Menu\LocalActionTest.
Class
- LocalActionTest
- Tests local actions derived from router and added/altered via hooks.
Namespace
Drupal\system\Tests\MenuCode
protected function assertLocalAction(array $actions) {
$elements = $this
->xpath('//a[contains(@class, :class)]', array(
':class' => 'button-action',
));
$index = 0;
foreach ($actions as $action) {
/** @var \Drupal\Core\Url $url */
list($url, $title) = $action;
// SimpleXML gives us the unescaped text, not the actual escaped markup,
// so use a pattern instead to check the raw content.
// This behaviour is a bug in libxml, see
// https://bugs.php.net/bug.php?id=49437.
$this
->assertPattern('@<a [^>]*class="[^"]*button-action[^"]*"[^>]*>' . preg_quote($title, '@') . '</@');
$this
->assertEqual($elements[$index]['href'], $url
->toString());
$index++;
}
}