protected function LocalTasksTest::assertLocalTasks in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Menu/LocalTasksTest.php \Drupal\system\Tests\Menu\LocalTasksTest::assertLocalTasks()
Asserts local tasks in the page output.
Parameters
array $routes: A list of expected local tasks, prepared as an array of route names and their associated route parameters, to assert on the page (in the given order).
int $level: (optional) The local tasks level to assert; 0 for primary, 1 for secondary. Defaults to 0.
2 calls to LocalTasksTest::assertLocalTasks()
- LocalTasksTest::testLocalTaskBlock in core/
modules/ system/ src/ Tests/ Menu/ LocalTasksTest.php - Tests that local task blocks are configurable to show a specific level.
- LocalTasksTest::testPluginLocalTask in core/
modules/ system/ src/ Tests/ Menu/ LocalTasksTest.php - Tests the plugin based local tasks.
File
- core/
modules/ system/ src/ Tests/ Menu/ LocalTasksTest.php, line 55 - Contains \Drupal\system\Tests\Menu\LocalTasksTest.
Class
- LocalTasksTest
- Tests local tasks derived from router and added/altered via hooks.
Namespace
Drupal\system\Tests\MenuCode
protected function assertLocalTasks(array $routes, $level = 0) {
$elements = $this
->xpath('//*[contains(@class, :class)]//a', array(
':class' => $level == 0 ? 'tabs primary' : 'tabs secondary',
));
$this
->assertTrue(count($elements), 'Local tasks found.');
foreach ($routes as $index => $route_info) {
list($route_name, $route_parameters) = $route_info;
$expected = Url::fromRoute($route_name, $route_parameters)
->toString();
$method = $elements[$index]['href'] == $expected ? 'pass' : 'fail';
$this
->{$method}(format_string('Task @number href @value equals @expected.', array(
'@number' => $index + 1,
'@value' => (string) $elements[$index]['href'],
'@expected' => $expected,
)));
}
}