You are here

protected function PageVariantTest::setUp in Page Manager 8

Same name and namespace in other branches
  1. 8.4 tests/src/Unit/PageVariantTest.php \Drupal\Tests\page_manager\Unit\PageVariantTest::setUp()

Overrides UnitTestCase::setUp

File

tests/src/Unit/PageVariantTest.php, line 43
Contains \Drupal\Tests\page_manager\Unit\PageVariantTest.

Class

PageVariantTest
@coversDefaultClass \Drupal\page_manager\Entity\PageVariant

Namespace

Drupal\Tests\page_manager\Unit

Code

protected function setUp() {
  parent::setUp();
  $this->pageVariant = new PageVariant([
    'id' => 'the_page_variant',
    'page' => 'the_page',
  ], 'page_variant');
  $this->page = $this
    ->prophesize(PageInterface::class);
  $entity_storage = $this
    ->prophesize(EntityStorageInterface::class);
  $entity_storage
    ->load('the_page')
    ->willReturn($this->page
    ->reveal());
  $entity_type_manager = $this
    ->prophesize(EntityTypeManagerInterface::class);
  $entity_type_manager
    ->getStorage('page')
    ->willReturn($entity_storage);
  $this->contextMapper = $this
    ->prophesize(ContextMapperInterface::class);
  $container = new ContainerBuilder();
  $container
    ->set('entity_type.manager', $entity_type_manager
    ->reveal());
  $container
    ->set('page_manager.context_mapper', $this->contextMapper
    ->reveal());
  \Drupal::setContainer($container);
}