public function FormAjaxResponseBuilderTest::testBuildResponseRenderArray in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Form/FormAjaxResponseBuilderTest.php \Drupal\Tests\Core\Form\FormAjaxResponseBuilderTest::testBuildResponseRenderArray()
@covers ::buildResponse
File
- core/
tests/ Drupal/ Tests/ Core/ Form/ FormAjaxResponseBuilderTest.php, line 90 - Contains \Drupal\Tests\Core\Form\FormAjaxResponseBuilderTest.
Class
- FormAjaxResponseBuilderTest
- @coversDefaultClass \Drupal\Core\Form\FormAjaxResponseBuilder @group Form
Namespace
Drupal\Tests\Core\FormCode
public function testBuildResponseRenderArray() {
$triggering_element = [
'#ajax' => [
'callback' => function (array $form, FormStateInterface $form_state) {
return $form['test'];
},
],
];
$request = new Request();
$form = [
'test' => [
'#type' => 'textfield',
],
];
$form_state = new FormState();
$form_state
->setTriggeringElement($triggering_element);
$commands = [];
$this->renderer
->expects($this
->once())
->method('renderResponse')
->with($form['test'], $request, $this->routeMatch)
->willReturn(new AjaxResponse([]));
$result = $this->formAjaxResponseBuilder
->buildResponse($request, $form, $form_state, $commands);
$this
->assertInstanceOf('\\Drupal\\Core\\Ajax\\AjaxResponse', $result);
$this
->assertSame($commands, $result
->getCommands());
}