function LocalActionManagerTest::setUp

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php \Drupal\Tests\Core\Menu\LocalActionManagerTest::setUp()
  2. 8.9.x core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php \Drupal\Tests\Core\Menu\LocalActionManagerTest::setUp()
  3. 10 core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php \Drupal\Tests\Core\Menu\LocalActionManagerTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php, line 107

Class

LocalActionManagerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Menu%21LocalActionManager.php/class/LocalActionManager/11.x" title="Provides the default local action manager using YML as primary definition." class="local">\Drupal\Core\Menu\LocalActionManager</a> @group Menu

Namespace

Drupal\Tests\Core\Menu

Code

protected function setUp() : void {
    parent::setUp();
    $this->argumentResolver = $this->createMock('\\Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface');
    $this->request = $this->createMock('Symfony\\Component\\HttpFoundation\\Request');
    $this->routeProvider = $this->createMock('Drupal\\Core\\Routing\\RouteProviderInterface');
    $this->moduleHandler = $this->createMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
    $this->cacheBackend = $this->createMock('Drupal\\Core\\Cache\\CacheBackendInterface');
    $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);
    $access_result = (new AccessResultForbidden())->cachePerPermissions();
    $this->accessManager = $this->createMock('Drupal\\Core\\Access\\AccessManagerInterface');
    $this->accessManager
        ->expects($this->any())
        ->method('checkNamedRoute')
        ->willReturn($access_result);
    $this->account = $this->createMock('Drupal\\Core\\Session\\AccountInterface');
    $this->discovery = $this->createMock('Drupal\\Component\\Plugin\\Discovery\\DiscoveryInterface');
    $this->factory = $this->createMock('Drupal\\Component\\Plugin\\Factory\\FactoryInterface');
    $route_match = $this->createMock('Drupal\\Core\\Routing\\RouteMatchInterface');
    $this->localActionManager = new TestLocalActionManager($this->argumentResolver, $this->request, $route_match, $this->routeProvider, $this->moduleHandler, $this->cacheBackend, $this->accessManager, $this->account, $this->discovery, $this->factory);
}

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