public function LocalActionManagerTest::getActionsForRouteProvider in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php \Drupal\Tests\Core\Menu\LocalActionManagerTest::getActionsForRouteProvider()
- 9 core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php \Drupal\Tests\Core\Menu\LocalActionManagerTest::getActionsForRouteProvider()
File
- core/
tests/ Drupal/ Tests/ Core/ Menu/ LocalActionManagerTest.php, line 196 - Contains \Drupal\Tests\Core\Menu\LocalActionManagerTest.
Class
- LocalActionManagerTest
- @coversDefaultClass \Drupal\Core\Menu\LocalActionManager @group Menu
Namespace
Drupal\Tests\Core\MenuCode
public function getActionsForRouteProvider() {
$cache_contexts_manager = $this
->prophesize(CacheContextsManager::class);
$cache_contexts_manager
->assertValidTokens(Argument::any())
->willReturn(TRUE);
$container = new Container();
$container
->set('cache_contexts_manager', $cache_contexts_manager
->reveal());
\Drupal::setContainer($container);
// Single available and single expected plugins.
$data[] = [
'test_route',
[
'plugin_id_1' => [
'appears_on' => [
'test_route',
],
'route_name' => 'test_route_2',
'title' => 'Plugin ID 1',
'weight' => 0,
],
],
[
'#cache' => [
'tags' => [],
'contexts' => [
'route',
'user.permissions',
],
'max-age' => 0,
],
'plugin_id_1' => [
'#theme' => 'menu_local_action',
'#link' => [
'title' => 'Plugin ID 1',
'url' => Url::fromRoute('test_route_2'),
'localized_options' => '',
],
'#access' => AccessResult::forbidden()
->cachePerPermissions(),
'#weight' => 0,
],
],
];
// Multiple available and single expected plugins.
$data[] = [
'test_route',
[
'plugin_id_1' => [
'appears_on' => [
'test_route',
],
'route_name' => 'test_route_2',
'title' => 'Plugin ID 1',
'weight' => 0,
],
'plugin_id_2' => [
'appears_on' => [
'test_route2',
],
'route_name' => 'test_route_3',
'title' => 'Plugin ID 2',
'weight' => 0,
],
],
[
'#cache' => [
'tags' => [],
'contexts' => [
'route',
'user.permissions',
],
'max-age' => 0,
],
'plugin_id_1' => [
'#theme' => 'menu_local_action',
'#link' => [
'title' => 'Plugin ID 1',
'url' => Url::fromRoute('test_route_2'),
'localized_options' => '',
],
'#access' => AccessResult::forbidden()
->cachePerPermissions(),
'#weight' => 0,
],
],
];
// Multiple available and multiple expected plugins and specified weight.
$data[] = [
'test_route',
[
'plugin_id_1' => [
'appears_on' => [
'test_route',
],
'route_name' => 'test_route_2',
'title' => 'Plugin ID 1',
'weight' => 1,
],
'plugin_id_2' => [
'appears_on' => [
'test_route',
],
'route_name' => 'test_route_3',
'title' => 'Plugin ID 2',
'weight' => 0,
],
],
[
'#cache' => [
'contexts' => [
'route',
'user.permissions',
],
'tags' => [],
'max-age' => 0,
],
'plugin_id_1' => [
'#theme' => 'menu_local_action',
'#link' => [
'title' => 'Plugin ID 1',
'url' => Url::fromRoute('test_route_2'),
'localized_options' => '',
],
'#access' => AccessResult::forbidden()
->cachePerPermissions(),
'#weight' => 1,
],
'plugin_id_2' => [
'#theme' => 'menu_local_action',
'#link' => [
'title' => 'Plugin ID 2',
'url' => Url::fromRoute('test_route_3'),
'localized_options' => '',
],
'#access' => AccessResult::forbidden()
->cachePerPermissions(),
'#weight' => 0,
],
],
];
// Two plugins with the same route name but different route parameters.
$data[] = [
'test_route',
[
'plugin_id_1' => [
'appears_on' => [
'test_route',
],
'route_name' => 'test_route_2',
'route_parameters' => [
'test1',
],
'title' => 'Plugin ID 1',
'weight' => 1,
],
'plugin_id_2' => [
'appears_on' => [
'test_route',
],
'route_name' => 'test_route_2',
'route_parameters' => [
'test2',
],
'title' => 'Plugin ID 2',
'weight' => 0,
],
],
[
'#cache' => [
'contexts' => [
'route',
'user.permissions',
],
'tags' => [],
'max-age' => 0,
],
'plugin_id_1' => [
'#theme' => 'menu_local_action',
'#link' => [
'title' => 'Plugin ID 1',
'url' => Url::fromRoute('test_route_2', [
'test1',
]),
'localized_options' => '',
],
'#access' => AccessResult::forbidden()
->cachePerPermissions(),
'#weight' => 1,
],
'plugin_id_2' => [
'#theme' => 'menu_local_action',
'#link' => [
'title' => 'Plugin ID 2',
'url' => Url::fromRoute('test_route_2', [
'test2',
]),
'localized_options' => '',
],
'#access' => AccessResult::forbidden()
->cachePerPermissions(),
'#weight' => 0,
],
],
];
return $data;
}