You are here

protected function ViewAjaxControllerTest::setUp in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php \Drupal\Tests\views\Unit\Controller\ViewAjaxControllerTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php, line 69
Contains \Drupal\Tests\views\Unit\Controller\ViewAjaxControllerTest.

Class

ViewAjaxControllerTest
@coversDefaultClass \Drupal\views\Controller\ViewAjaxController @group views

Namespace

Drupal\Tests\views\Unit\Controller

Code

protected function setUp() {
  $this->viewStorage = $this
    ->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
  $this->executableFactory = $this
    ->getMockBuilder('Drupal\\views\\ViewExecutableFactory')
    ->disableOriginalConstructor()
    ->getMock();
  $this->renderer = $this
    ->getMock('\\Drupal\\Core\\Render\\RendererInterface');
  $this->renderer
    ->expects($this
    ->any())
    ->method('render')
    ->will($this
    ->returnCallback(function (array &$elements) {
    $elements['#attached'] = [];
    return isset($elements['#markup']) ? $elements['#markup'] : '';
  }));
  $this->renderer
    ->expects($this
    ->any())
    ->method('executeInRenderContext')
    ->willReturnCallback(function (RenderContext $context, callable $callable) {
    return $callable();
  });
  $this->currentPath = $this
    ->getMockBuilder('Drupal\\Core\\Path\\CurrentPathStack')
    ->disableOriginalConstructor()
    ->getMock();
  $this->redirectDestination = $this
    ->getMock('\\Drupal\\Core\\Routing\\RedirectDestinationInterface');
  $this->viewAjaxController = new ViewAjaxController($this->viewStorage, $this->executableFactory, $this->renderer, $this->currentPath, $this->redirectDestination);
  $element_info_manager = $this
    ->getMock('\\Drupal\\Core\\Render\\ElementInfoManagerInterface');
  $request_stack = new RequestStack();
  $request_stack
    ->push(new Request());
  $args = [
    $this
      ->getMock('\\Drupal\\Core\\Controller\\ControllerResolverInterface'),
    $this
      ->getMock('\\Drupal\\Core\\Theme\\ThemeManagerInterface'),
    $element_info_manager,
    $this
      ->getMock('\\Drupal\\Core\\Render\\PlaceholderGeneratorInterface'),
    $this
      ->getMock('\\Drupal\\Core\\Render\\RenderCacheInterface'),
    $request_stack,
    [
      'required_cache_contexts' => [
        'languages:language_interface',
        'theme',
      ],
    ],
  ];
  $this->renderer = $this
    ->getMockBuilder('Drupal\\Core\\Render\\Renderer')
    ->setConstructorArgs($args)
    ->setMethods(NULL)
    ->getMock();
  $container = new ContainerBuilder();
  $container
    ->set('renderer', $this->renderer);
  \Drupal::setContainer($container);
}