function LocalTaskDefaultTest::providerTestGetWeight

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php \Drupal\Tests\Core\Menu\LocalTaskDefaultTest::providerTestGetWeight()
  2. 8.9.x core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php \Drupal\Tests\Core\Menu\LocalTaskDefaultTest::providerTestGetWeight()
  3. 11.x core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php \Drupal\Tests\Core\Menu\LocalTaskDefaultTest::providerTestGetWeight()

Defines a data provider for testGetWeight().

Return value

array A list or test plugin definition and expected weight.

File

core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php, line 193

Class

LocalTaskDefaultTest
@coversDefaultClass \Drupal\Core\Menu\LocalTaskDefault @group Menu

Namespace

Drupal\Tests\Core\Menu

Code

public static function providerTestGetWeight() {
    return [
        // Manually specify a weight, so this is used.
[
            [
                'weight' => 314,
            ],
            'test_id',
            314,
        ],
        // Ensure that a default tab gets a lower weight.
[
            [
                'base_route' => 'local_task_default',
                'route_name' => 'local_task_default',
                'id' => 'local_task_default',
            ],
            'local_task_default',
            -10,
        ],
        // If the base route is different from the route of the tab, ignore it.
[
            [
                'base_route' => 'local_task_example',
                'route_name' => 'local_task_other',
                'id' => 'local_task_default',
            ],
            'local_task_default',
            0,
        ],
        // Ensure that a default tab of a derivative gets the default value.
[
            [
                'base_route' => 'local_task_example',
                'id' => 'local_task_derivative_default:example_id',
                'route_name' => 'local_task_example',
            ],
            'local_task_derivative_default:example_id',
            -10,
        ],
    ];
}

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