You are here

protected function PathBasedBreadcrumbBuilderTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::setUp()

@covers ::__construct

Overrides UnitTestCase::setUp

File

core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php, line 92
Contains \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest.

Class

PathBasedBreadcrumbBuilderTest
@coversDefaultClass \Drupal\system\PathBasedBreadcrumbBuilder @group system

Namespace

Drupal\Tests\system\Unit\Breadcrumbs

Code

protected function setUp() {
  parent::setUp();
  $this->requestMatcher = $this
    ->getMock('\\Symfony\\Component\\Routing\\Matcher\\RequestMatcherInterface');
  $config_factory = $this
    ->getConfigFactoryStub(array(
    'system.site' => array(
      'front' => 'test_frontpage',
    ),
  ));
  $this->pathProcessor = $this
    ->getMock('\\Drupal\\Core\\PathProcessor\\InboundPathProcessorInterface');
  $this->context = $this
    ->getMock('\\Drupal\\Core\\Routing\\RequestContext');
  $this->accessManager = $this
    ->getMock('\\Drupal\\Core\\Access\\AccessManagerInterface');
  $this->titleResolver = $this
    ->getMock('\\Drupal\\Core\\Controller\\TitleResolverInterface');
  $this->currentUser = $this
    ->getMock('Drupal\\Core\\Session\\AccountInterface');
  $this->currentPath = $this
    ->getMockBuilder('Drupal\\Core\\Path\\CurrentPathStack')
    ->disableOriginalConstructor()
    ->getMock();
  $this->builder = new TestPathBasedBreadcrumbBuilder($this->context, $this->accessManager, $this->requestMatcher, $this->pathProcessor, $config_factory, $this->titleResolver, $this->currentUser, $this->currentPath);
  $this->builder
    ->setStringTranslation($this
    ->getStringTranslationStub());
  $cache_contexts_manager = $this
    ->getMockBuilder('Drupal\\Core\\Cache\\Context\\CacheContextsManager')
    ->disableOriginalConstructor()
    ->getMock();
  $cache_contexts_manager
    ->method('assertValidTokens')
    ->willReturn(TRUE);
  $cache_contexts_manager
    ->expects($this
    ->any())
    ->method('validate_tokens');
  $container = new Container();
  $container
    ->set('cache_contexts_manager', $cache_contexts_manager);
  \Drupal::setContainer($container);
}