function FormAjaxSubscriberTest::assertResponseFromException

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php \Drupal\Tests\Core\Form\EventSubscriber\FormAjaxSubscriberTest::assertResponseFromException()
  2. 8.9.x core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php \Drupal\Tests\Core\Form\EventSubscriber\FormAjaxSubscriberTest::assertResponseFromException()
  3. 11.x core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php \Drupal\Tests\Core\Form\EventSubscriber\FormAjaxSubscriberTest::assertResponseFromException()

Asserts that the expected response is derived from the given exception.

@internal

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request.

\Exception $exception: The exception to pass to the event.

\Symfony\Component\HttpFoundation\Response|null $expected_response: The response expected to be set on the event.

6 calls to FormAjaxSubscriberTest::assertResponseFromException()
FormAjaxSubscriberTest::testOnException in core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php
@covers ::onException
FormAjaxSubscriberTest::testOnExceptionNestedException in core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php
@covers ::onException @covers ::getFormAjaxException
FormAjaxSubscriberTest::testOnExceptionNestedWrongException in core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php
@covers ::getFormAjaxException
FormAjaxSubscriberTest::testOnExceptionNewBuildId in core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php
@covers ::onException
FormAjaxSubscriberTest::testOnExceptionOtherClass in core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php
@covers ::onException

... See full list

File

core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php, line 259

Class

FormAjaxSubscriberTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Form%21EventSubscriber%21FormAjaxSubscriber.php/class/FormAjaxSubscriber/10" 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\EventSubscriber

Code

protected function assertResponseFromException(Request $request, \Exception $exception, ?Response $expected_response) : void {
    $this->event = new ExceptionEvent($this->httpKernel, $request, HttpKernelInterface::MAIN_REQUEST, $exception);
    $this->subscriber
        ->onException($this->event);
    $this->assertSame($expected_response, $this->event
        ->getResponse());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.