You are here

protected function LocalTaskIntegrationTestBase::assertLocalTasks in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php \Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase::assertLocalTasks()
  2. 9 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.

18 calls to LocalTaskIntegrationTestBase::assertLocalTasks()
ActionLocalTasksTest::testActionLocalTasks in core/modules/action/tests/src/Unit/Menu/ActionLocalTasksTest.php
Tests local task existence.
BlockContentLocalTasksTest::testBlockContentListLocalTasks in core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php
Checks block_content listing local tasks.
BlockLocalTasksTest::testBlockAdminDisplay in core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php
Tests the block admin display local tasks.
BlockLocalTasksTest::testBlockAdminLocalTasks in core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php
Tests the admin edit local task.
BookLocalTasksTest::testBookAdminLocalTasks in core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php
Tests local task existence.

... See full list

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\Menu

Code

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);
}