public function LocalActionManagerTest::testGetActionsForRoute in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php \Drupal\Tests\Core\Menu\LocalActionManagerTest::testGetActionsForRoute()
@covers ::getActionsForRoute
@dataProvider getActionsForRouteProvider
File
- core/
tests/ Drupal/ Tests/ Core/ Menu/ LocalActionManagerTest.php, line 162 - Contains \Drupal\Tests\Core\Menu\LocalActionManagerTest.
Class
- LocalActionManagerTest
- @coversDefaultClass \Drupal\Core\Menu\LocalActionManager @group Menu
Namespace
Drupal\Tests\Core\MenuCode
public function testGetActionsForRoute($route_appears, array $plugin_definitions, array $expected_actions) {
$this->discovery
->expects($this
->any())
->method('getDefinitions')
->will($this
->returnValue($plugin_definitions));
$map = [];
foreach ($plugin_definitions as $plugin_id => $plugin_definition) {
$plugin = $this
->createMock('Drupal\\Core\\Menu\\LocalActionInterface');
$plugin
->expects($this
->any())
->method('getRouteName')
->will($this
->returnValue($plugin_definition['route_name']));
$plugin
->expects($this
->any())
->method('getRouteParameters')
->will($this
->returnValue(isset($plugin_definition['route_parameters']) ? $plugin_definition['route_parameters'] : []));
$plugin
->expects($this
->any())
->method('getTitle')
->will($this
->returnValue($plugin_definition['title']));
$this->argumentResolver
->expects($this
->any())
->method('getArguments')
->with($this->request, [
$plugin,
'getTitle',
])
->will($this
->returnValue([]));
$plugin
->expects($this
->any())
->method('getWeight')
->will($this
->returnValue($plugin_definition['weight']));
$this->argumentResolver
->expects($this
->any())
->method('getArguments')
->with($this->request, [
$plugin,
'getTitle',
])
->will($this
->returnValue([]));
$map[] = [
$plugin_id,
[],
$plugin,
];
}
$this->factory
->expects($this
->any())
->method('createInstance')
->will($this
->returnValueMap($map));
$this
->assertEquals($expected_actions, $this->localActionManager
->getActionsForRoute($route_appears));
}