function FormAjaxSubscriberTest::testOnExceptionResponseBuilderException
Same name and namespace in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php \Drupal\Tests\Core\Form\EventSubscriber\FormAjaxSubscriberTest::testOnExceptionResponseBuilderException()
- 10 core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php \Drupal\Tests\Core\Form\EventSubscriber\FormAjaxSubscriberTest::testOnExceptionResponseBuilderException()
- 11.x core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php \Drupal\Tests\Core\Form\EventSubscriber\FormAjaxSubscriberTest::testOnExceptionResponseBuilderException()
@covers ::onException
File
-
core/
tests/ Drupal/ Tests/ Core/ Form/ EventSubscriber/ FormAjaxSubscriberTest.php, line 140
Class
- FormAjaxSubscriberTest
- @coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Form%21EventSubscriber%21FormAjaxSubscriber.php/class/FormAjaxSubscriber/9" title="Wraps AJAX form submissions that are triggered via an exception." class="local">\Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber</a> @group EventSubscriber
Namespace
Drupal\Tests\Core\Form\EventSubscriberCode
public function testOnExceptionResponseBuilderException() {
$form = [
'#type' => 'form',
'#build_id' => 'the_build_id',
];
$expected_form = $form + [
'#build_id_old' => 'the_build_id',
];
$form_state = new FormState();
$exception = new FormAjaxException($form, $form_state);
$request = new Request([], [
'form_build_id' => 'the_build_id',
]);
$commands = [];
$expected_exception = new HttpException(500, 'The specified #ajax callback is empty or not callable.');
$this->formAjaxResponseBuilder
->expects($this->once())
->method('buildResponse')
->with($request, $expected_form, $form_state, $commands)
->willThrowException($expected_exception);
$this->assertResponseFromException($request, $exception, NULL);
$this->assertSame($expected_exception, $this->event
->getThrowable());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.