function LocalTaskManagerTest::testGetLocalTaskForRouteWithEmptyCache

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

Tests the cache of the local task manager with an empty initial cache.

File

core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php, line 167

Class

LocalTaskManagerTest
@coversDefaultClass \Drupal\Core\Menu\LocalTaskManager @group Menu

Namespace

Drupal\Tests\Core\Menu

Code

public function testGetLocalTaskForRouteWithEmptyCache() {
    $definitions = $this->getLocalTaskFixtures();
    $this->pluginDiscovery
        ->expects($this->once())
        ->method('getDefinitions')
        ->willReturn($definitions);
    $mock_plugin = $this->createMock('Drupal\\Core\\Menu\\LocalTaskInterface');
    $this->setupFactory($mock_plugin);
    $this->setupLocalTaskManager();
    $result = $this->getLocalTasksForRouteResult($mock_plugin);
    $this->cacheBackend
        ->expects($this->exactly(2))
        ->method('get')
        ->withConsecutive([
        'local_task_plugins:en:menu_local_task_test_tasks_view',
    ], [
        'local_task_plugins:en',
    ]);
    $this->cacheBackend
        ->expects($this->exactly(2))
        ->method('set')
        ->withConsecutive([
        'local_task_plugins:en',
        $definitions,
        Cache::PERMANENT,
    ], [
        'local_task_plugins:en:menu_local_task_test_tasks_view',
        $this->getLocalTasksCache(),
        Cache::PERMANENT,
        [
            'local_task',
        ],
    ]);
    $local_tasks = $this->manager
        ->getLocalTasksForRoute('menu_local_task_test_tasks_view');
    $this->assertEquals($result, $local_tasks);
}

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