function LocalTaskManagerTest::setupFactoryAndLocalTaskPlugins
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php \Drupal\Tests\Core\Menu\LocalTaskManagerTest::setupFactoryAndLocalTaskPlugins()
- 10 core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php \Drupal\Tests\Core\Menu\LocalTaskManagerTest::setupFactoryAndLocalTaskPlugins()
- 11.x core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php \Drupal\Tests\Core\Menu\LocalTaskManagerTest::setupFactoryAndLocalTaskPlugins()
1 call to LocalTaskManagerTest::setupFactoryAndLocalTaskPlugins()
- LocalTaskManagerTest::testGetTasksBuildWithCacheabilityMetadata in core/
tests/ Drupal/ Tests/ Core/ Menu/ LocalTaskManagerTest.php - @covers ::getTasksBuild
File
-
core/
tests/ Drupal/ Tests/ Core/ Menu/ LocalTaskManagerTest.php, line 471
Class
- LocalTaskManagerTest
- @coversDefaultClass \Drupal\Core\Menu\LocalTaskManager @group Menu
Namespace
Drupal\Tests\Core\MenuCode
protected function setupFactoryAndLocalTaskPlugins(array $definitions, $active_plugin_id) {
$map = [];
$access_manager_map = [];
foreach ($definitions as $plugin_id => $info) {
$info += [
'access' => AccessResult::allowed(),
];
$mock = $this->prophesize(LocalTaskInterface::class);
$mock->willImplement(CacheableDependencyInterface::class);
$mock->getRouteName()
->willReturn($info['route_name']);
$mock->getTitle()
->willReturn($info['title']);
$mock->getRouteParameters(Argument::cetera())
->willReturn([]);
$mock->getOptions(Argument::cetera())
->willReturn([]);
$mock->getActive()
->willReturn($plugin_id === $active_plugin_id);
$mock->getWeight()
->willReturn(isset($info['weight']) ? $info['weight'] : 0);
$mock->getCacheContexts()
->willReturn(isset($info['cache_contexts']) ? $info['cache_contexts'] : []);
$mock->getCacheTags()
->willReturn(isset($info['cache_tags']) ? $info['cache_tags'] : []);
$mock->getCacheMaxAge()
->willReturn(isset($info['cache_max_age']) ? $info['cache_max_age'] : Cache::PERMANENT);
$access_manager_map[] = [
$info['route_name'],
[],
$this->account,
TRUE,
$info['access'],
];
$map[] = [
$info['id'],
[],
$mock->reveal(),
];
}
$this->accessManager
->expects($this->any())
->method('checkNamedRoute')
->willReturnMap($access_manager_map);
$this->factory
->expects($this->any())
->method('createInstance')
->will($this->returnValueMap($map));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.