You are here

public function BlockPageVariantTest::setUpDisplayVariant in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php \Drupal\Tests\block\Unit\Plugin\DisplayVariant\BlockPageVariantTest::setUpDisplayVariant()

Sets up a display variant plugin for testing.

Parameters

array $configuration: An array of plugin configuration.

array $definition: The plugin definition array.

Return value

\Drupal\block\Plugin\DisplayVariant\BlockPageVariant|\PHPUnit\Framework\MockObject\MockObject A mocked display variant plugin.

2 calls to BlockPageVariantTest::setUpDisplayVariant()
BlockPageVariantTest::testBuild in core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
Tests the building of a full page variant.
BlockPageVariantTest::testBuildWithoutMainContent in core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
Tests the building of a full page variant with no main content set.

File

core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php, line 47

Class

BlockPageVariantTest
@coversDefaultClass \Drupal\block\Plugin\DisplayVariant\BlockPageVariant @group block

Namespace

Drupal\Tests\block\Unit\Plugin\DisplayVariant

Code

public function setUpDisplayVariant($configuration = [], $definition = []) {
  $container = new Container();
  $cache_context_manager = $this
    ->getMockBuilder('Drupal\\Core\\Cache\\CacheContextsManager')
    ->disableOriginalConstructor()
    ->setMethods([
    'assertValidTokens',
  ])
    ->getMock();
  $container
    ->set('cache_contexts_manager', $cache_context_manager);
  $cache_context_manager
    ->expects($this
    ->any())
    ->method('assertValidTokens')
    ->willReturn(TRUE);
  \Drupal::setContainer($container);
  $this->blockRepository = $this
    ->createMock('Drupal\\block\\BlockRepositoryInterface');
  $this->blockViewBuilder = $this
    ->createMock('Drupal\\Core\\Entity\\EntityViewBuilderInterface');
  return $this
    ->getMockBuilder('Drupal\\block\\Plugin\\DisplayVariant\\BlockPageVariant')
    ->setConstructorArgs([
    $configuration,
    'test',
    $definition,
    $this->blockRepository,
    $this->blockViewBuilder,
    [
      'config:block_list',
    ],
  ])
    ->setMethods([
    'getRegionNames',
  ])
    ->getMock();
}