function ViewAjaxControllerTest::setUp
Same name in other branches
- 9 core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php \Drupal\Tests\views\Unit\Controller\ViewAjaxControllerTest::setUp()
- 8.9.x core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php \Drupal\Tests\views\Unit\Controller\ViewAjaxControllerTest::setUp()
- 10 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 74
Class
- ViewAjaxControllerTest
- @coversDefaultClass \Drupal\views\Controller\ViewAjaxController @group views
Namespace
Drupal\Tests\views\Unit\ControllerCode
protected function setUp() : void {
parent::setUp();
$this->viewStorage = $this->createMock('Drupal\\Core\\Entity\\EntityStorageInterface');
$this->executableFactory = $this->getMockBuilder('Drupal\\views\\ViewExecutableFactory')
->disableOriginalConstructor()
->getMock();
$this->renderer = $this->createMock('\\Drupal\\Core\\Render\\RendererInterface');
$this->renderer
->expects($this->any())
->method('renderRoot')
->willReturnCallback(function (array &$elements) {
$elements['#attached'] = [];
return $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->createMock('\\Drupal\\Core\\Routing\\RedirectDestinationInterface');
$this->viewAjaxController = new ViewAjaxController($this->viewStorage, $this->executableFactory, $this->renderer, $this->currentPath, $this->redirectDestination);
$element_info_manager = $this->createMock('\\Drupal\\Core\\Render\\ElementInfoManagerInterface');
$element_info_manager->expects($this->any())
->method('getInfo')
->with('status_messages')
->willReturn([]);
$request_stack = new RequestStack();
$request_stack->push(new Request());
$this->renderer = new Renderer($this->createMock(CallableResolver::class), $this->createMock('\\Drupal\\Core\\Theme\\ThemeManagerInterface'), $element_info_manager, $this->createMock('\\Drupal\\Core\\Render\\PlaceholderGeneratorInterface'), $this->createMock('\\Drupal\\Core\\Render\\RenderCacheInterface'), $request_stack, [
'required_cache_contexts' => [
'languages:language_interface',
'theme',
],
]);
$container = new ContainerBuilder();
$container->set('renderer', $this->renderer);
\Drupal::setContainer($container);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.