You are here

public function LocalTaskDefaultTest::providerTestGetWeight in Drupal 9

Same name and namespace in other branches
  1. 8 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
Contains \Drupal\Tests\Core\Menu\LocalTaskDefaultTest.

Class

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

Namespace

Drupal\Tests\Core\Menu

Code

public 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,
    ],
  ];
}