function AjaxRendererTest::setUp
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Controller/AjaxRendererTest.php \Drupal\Tests\Core\Controller\AjaxRendererTest::setUp()
- 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()
Overrides UnitTestCase::setUp
File
-
core/
tests/ Drupal/ Tests/ Core/ Controller/ AjaxRendererTest.php, line 35
Class
- AjaxRendererTest
- @coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Render%21MainContent%21AjaxRenderer.php/class/AjaxRenderer/11.x" title="Default main content renderer for Ajax requests." class="local">\Drupal\Core\Render\MainContent\AjaxRenderer</a> @group Ajax
Namespace
Drupal\Tests\Core\ControllerCode
protected function setUp() : void {
parent::setUp();
$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.