You are here

protected function LinksWidgetTest::createContainer in Facets 8

Sets up a container.

1 call to LinksWidgetTest::createContainer()
LinksWidgetTest::testResetLink in tests/src/Unit/Plugin/widget/LinksWidgetTest.php
Tests the rest link.

File

tests/src/Unit/Plugin/widget/LinksWidgetTest.php, line 246

Class

LinksWidgetTest
Unit test for widget.

Namespace

Drupal\Tests\facets\Unit\Plugin\widget

Code

protected function createContainer() {
  $router = $this
    ->getMockBuilder(TestRouterInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $router
    ->expects($this
    ->any())
    ->method('matchRequest')
    ->willReturn([
    '_raw_variables' => new ParameterBag([]),
    '_route' => 'test',
  ]);
  $url_processor = $this
    ->getMockBuilder(UrlProcessorInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $manager = $this
    ->getMockBuilder(FacetSourcePluginManager::class)
    ->disableOriginalConstructor()
    ->getMock();
  $manager
    ->expects($this
    ->exactly(1))
    ->method('createInstance')
    ->willReturn($url_processor);
  $storage = $this
    ->createMock(EntityStorageInterface::class);
  $em = $this
    ->getMockBuilder(EntityTypeManagerInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $em
    ->expects($this
    ->exactly(1))
    ->method('getStorage')
    ->willReturn($storage);
  $container = new ContainerBuilder();
  $container
    ->set('router.no_access_checks', $router);
  $container
    ->set('entity_type.manager', $em);
  $container
    ->set('plugin.manager.facets.url_processor', $manager);
  \Drupal::setContainer($container);
}