public function AjaxRendererTest::testRenderWithFragmentObject in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Controller/AjaxRendererTest.php \Drupal\Tests\Core\Controller\AjaxRendererTest::testRenderWithFragmentObject()
- 10 core/tests/Drupal/Tests/Core/Controller/AjaxRendererTest.php \Drupal\Tests\Core\Controller\AjaxRendererTest::testRenderWithFragmentObject()
Tests the content method.
@covers ::renderResponse
File
- core/
tests/ Drupal/ Tests/ Core/ Controller/ AjaxRendererTest.php, line 69
Class
- AjaxRendererTest
- @coversDefaultClass \Drupal\Core\Render\MainContent\AjaxRenderer @group Ajax
Namespace
Drupal\Tests\Core\ControllerCode
public function testRenderWithFragmentObject() {
$main_content = [
'#markup' => 'example content',
];
$request = new Request();
$route_match = $this
->createMock('Drupal\\Core\\Routing\\RouteMatchInterface');
/** @var \Drupal\Core\Ajax\AjaxResponse $result */
$result = $this->ajaxRenderer
->renderResponse($main_content, $request, $route_match);
$this
->assertInstanceOf('Drupal\\Core\\Ajax\\AjaxResponse', $result);
$commands = $result
->getCommands();
$this
->assertEquals('insert', $commands[0]['command']);
$this
->assertEquals('example content', $commands[0]['data']);
$this
->assertEquals('insert', $commands[1]['command']);
$this
->assertEquals('status_messages', $commands[1]['data']);
}