function LocalTaskIntegrationTestBase::assertLocalTasks
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php \Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase::assertLocalTasks()
Tests integration for local tasks.
Parameters
$route_name: Route name to base task building on.
$expected_tasks: A list of tasks groups by level expected at the given route
array $route_params: (optional) A list of route parameters used to resolve tasks.
4 calls to LocalTaskIntegrationTestBase::assertLocalTasks()
- LanguageLocalTasksTest::testLanguageAdminLocalTasks in core/
modules/ language/ tests/ src/ Unit/ Menu/ LanguageLocalTasksTest.php - Tests language admin overview local tasks existence.
- LanguageLocalTasksTest::testLanguageEditLocalTasks in core/
modules/ language/ tests/ src/ Unit/ Menu/ LanguageLocalTasksTest.php - Tests language edit local tasks existence.
- LocaleLocalTasksTest::testLocalePageLocalTasks in core/
modules/ locale/ tests/ src/ Unit/ Menu/ LocaleLocalTasksTest.php - Checks locale listing local tasks.
- SystemLocalTasksTest::testSystemAdminLocalTasks in core/
modules/ system/ tests/ src/ Unit/ Menu/ SystemLocalTasksTest.php - Tests local task existence.
File
-
core/
tests/ Drupal/ Tests/ Core/ Menu/ LocalTaskIntegrationTestBase.php, line 133
Class
- LocalTaskIntegrationTestBase
- Defines a base unit test for testing existence of local tasks.
Namespace
Drupal\Tests\Core\MenuCode
protected function assertLocalTasks($route_name, $expected_tasks, $route_params = []) {
$directory_list = [];
foreach ($this->directoryList as $key => $value) {
$directory_list[$key] = $this->root . '/' . $value;
}
$manager = $this->getLocalTaskManager($directory_list, $route_name, $route_params);
$tmp_tasks = $manager->getLocalTasksForRoute($route_name);
// At this point we're just testing existence so pull out keys and then
// compare.
//
// Deeper testing would require a functioning factory which because we are
// using the DefaultPluginManager base means we get into dependency soup
// because its factories create method and pulling services off the \Drupal
// container.
$tasks = [];
foreach ($tmp_tasks as $level => $level_tasks) {
$tasks[$level] = array_keys($level_tasks);
}
$this->assertEquals($expected_tasks, $tasks);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.