function AjaxRendererTest::setUp
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Controller/AjaxRendererTest.php \Drupal\Tests\Core\Controller\AjaxRendererTest::setUp()
- 10 core/tests/Drupal/Tests/Core/Controller/AjaxRendererTest.php \Drupal\Tests\Core\Controller\AjaxRendererTest::setUp()
- 11.x core/tests/Drupal/Tests/Core/Controller/AjaxRendererTest.php \Drupal\Tests\Core\Controller\AjaxRendererTest::setUp()
Overrides UnitTestCase::setUp
File
-
core/
tests/ Drupal/ Tests/ Core/ Controller/ AjaxRendererTest.php, line 33
Class
- AjaxRendererTest
- @coversDefaultClass \Drupal\Core\Render\MainContent\AjaxRenderer @group Ajax
Namespace
Drupal\Tests\Core\ControllerCode
protected function setUp() : void {
$element_info_manager = $this->createMock('Drupal\\Core\\Render\\ElementInfoManagerInterface');
$element_info_manager->expects($this->any())
->method('getInfo')
->with('ajax')
->willReturn([
'#header' => TRUE,
'#commands' => [],
'#error' => NULL,
]);
$renderer = $this->createMock(RendererInterface::class);
$renderer->expects($this->any())
->method('renderRoot')
->willReturnCallback(function (&$elements, $is_root_call = FALSE) {
$elements += [
'#attached' => [],
];
if (isset($elements['#markup'])) {
return $elements['#markup'];
}
elseif (isset($elements['#type'])) {
return $elements['#type'];
}
else {
return 'Markup';
}
});
$this->ajaxRenderer = new AjaxRenderer($element_info_manager, $renderer);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.