function ContextualLinkManagerTest::setUp

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

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php, line 70

Class

ContextualLinkManagerTest
@coversDefaultClass \Drupal\Core\Menu\ContextualLinkManager @group Menu

Namespace

Drupal\Tests\Core\Menu

Code

protected function setUp() : void {
    parent::setUp();
    $language_manager = $this->createMock(LanguageManagerInterface::class);
    $language_manager->expects($this->any())
        ->method('getCurrentLanguage')
        ->willReturn(new Language([
        'id' => 'en',
    ]));
    $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
    $this->pluginDiscovery = $this->createMock('Drupal\\Component\\Plugin\\Discovery\\DiscoveryInterface');
    $this->cacheBackend = $this->createMock('Drupal\\Core\\Cache\\CacheBackendInterface');
    $this->accessManager = $this->createMock('Drupal\\Core\\Access\\AccessManagerInterface');
    $this->account = $this->createMock('Drupal\\Core\\Session\\AccountInterface');
    $this->contextualLinkManager = new ContextualLinkManager($this->createMock(ControllerResolverInterface::class), $this->moduleHandler
        ->reveal(), $this->cacheBackend, $language_manager, $this->accessManager, $this->account, new RequestStack());
    $property = new \ReflectionProperty('Drupal\\Core\\Menu\\ContextualLinkManager', 'discovery');
    $property->setValue($this->contextualLinkManager, $this->pluginDiscovery);
}

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