You are here

protected function ContextualLinkManagerTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 77
Contains \Drupal\Tests\Core\Menu\ContextualLinkManagerTest.

Class

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

Namespace

Drupal\Tests\Core\Menu

Code

protected function setUp() {
  $this->contextualLinkManager = $this
    ->getMockBuilder('Drupal\\Core\\Menu\\ContextualLinkManager')
    ->disableOriginalConstructor()
    ->setMethods(NULL)
    ->getMock();
  $this->controllerResolver = $this
    ->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
  $this->pluginDiscovery = $this
    ->getMock('Drupal\\Component\\Plugin\\Discovery\\DiscoveryInterface');
  $this->factory = $this
    ->getMock('Drupal\\Component\\Plugin\\Factory\\FactoryInterface');
  $this->cacheBackend = $this
    ->getMock('Drupal\\Core\\Cache\\CacheBackendInterface');
  $this->moduleHandler = $this
    ->getMock('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
  $this->accessManager = $this
    ->getMock('Drupal\\Core\\Access\\AccessManagerInterface');
  $this->account = $this
    ->getMock('Drupal\\Core\\Session\\AccountInterface');
  $property = new \ReflectionProperty('Drupal\\Core\\Menu\\ContextualLinkManager', 'controllerResolver');
  $property
    ->setAccessible(TRUE);
  $property
    ->setValue($this->contextualLinkManager, $this->controllerResolver);
  $property = new \ReflectionProperty('Drupal\\Core\\Menu\\ContextualLinkManager', 'discovery');
  $property
    ->setAccessible(TRUE);
  $property
    ->setValue($this->contextualLinkManager, $this->pluginDiscovery);
  $property = new \ReflectionProperty('Drupal\\Core\\Menu\\ContextualLinkManager', 'factory');
  $property
    ->setAccessible(TRUE);
  $property
    ->setValue($this->contextualLinkManager, $this->factory);
  $property = new \ReflectionProperty('Drupal\\Core\\Menu\\ContextualLinkManager', 'account');
  $property
    ->setAccessible(TRUE);
  $property
    ->setValue($this->contextualLinkManager, $this->account);
  $property = new \ReflectionProperty('Drupal\\Core\\Menu\\ContextualLinkManager', 'accessManager');
  $property
    ->setAccessible(TRUE);
  $property
    ->setValue($this->contextualLinkManager, $this->accessManager);
  $property = new \ReflectionProperty('Drupal\\Core\\Menu\\ContextualLinkManager', 'moduleHandler');
  $property
    ->setAccessible(TRUE);
  $property
    ->setValue($this->contextualLinkManager, $this->moduleHandler);
  $language_manager = $this
    ->getMock('Drupal\\Core\\Language\\LanguageManagerInterface');
  $language_manager
    ->expects($this
    ->any())
    ->method('getCurrentLanguage')
    ->will($this
    ->returnValue(new Language(array(
    'id' => 'en',
  ))));
  $request_stack = new RequestStack();
  $property = new \ReflectionProperty('Drupal\\Core\\Menu\\ContextualLinkManager', 'requestStack');
  $property
    ->setAccessible(TRUE);
  $property
    ->setValue($this->contextualLinkManager, $request_stack);
  $method = new \ReflectionMethod('Drupal\\Core\\Menu\\ContextualLinkManager', 'alterInfo');
  $method
    ->setAccessible(TRUE);
  $method
    ->invoke($this->contextualLinkManager, 'contextual_links_plugins');
  $this->contextualLinkManager
    ->setCacheBackend($this->cacheBackend, 'contextual_links_plugins:en');
}