function LocalTaskManagerTest::providerTestGetLocalTasks

Data provider for testGetLocalTasks.

File

core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php, line 542

Class

LocalTaskManagerTest
@coversDefaultClass \Drupal\Core\Menu\LocalTaskManager @group Menu

Namespace

Drupal\Tests\Core\Menu

Code

public static function providerTestGetLocalTasks() : array {
    return [
        // Weights as setup in getLocalTaskFixtures.
'weights_from_fixture' => [
            'new_weights' => [],
            'expected' => [
                // Level 0.
[
                    'menu_local_task_test_tasks_settings',
                    'menu_local_task_test_tasks_view.tab',
                    'menu_local_task_test_tasks_edit',
                ],
                // Level 1. All weights are 0, so the sort is alphabetical.
[
                    'menu_local_task_test_tasks_view_a_child',
                    'menu_local_task_test_tasks_view_child1',
                    'menu_local_task_test_tasks_view_child2',
                ],
            ],
        ],
        // Change the weights in both levels.
'both_levels' => [
            'new_weights' => [
                'menu_local_task_test_tasks_view_a_child' => [
                    'weight' => 99,
                ],
                'menu_local_task_test_tasks_view_child1' => [
                    'weight' => 100,
                ],
                'menu_local_task_test_tasks_view_child2' => [
                    'weight' => -1,
                ],
                'menu_local_task_test_tasks_settings' => [
                    'weight' => 100,
                ],
            ],
            'expected' => [
                // Level 0.
[
                    'menu_local_task_test_tasks_view.tab',
                    'menu_local_task_test_tasks_edit',
                    'menu_local_task_test_tasks_settings',
                ],
                // Level 1.
[
                    'menu_local_task_test_tasks_view_child2',
                    'menu_local_task_test_tasks_view_a_child',
                    'menu_local_task_test_tasks_view_child1',
                ],
            ],
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.