function ExceptionJsonSubscriberTest::providerTestOn4xx

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/EventSubscriber/ExceptionJsonSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\ExceptionJsonSubscriberTest::providerTestOn4xx()
  2. 10 core/tests/Drupal/Tests/Core/EventSubscriber/ExceptionJsonSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\ExceptionJsonSubscriberTest::providerTestOn4xx()
  3. 11.x core/tests/Drupal/Tests/Core/EventSubscriber/ExceptionJsonSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\ExceptionJsonSubscriberTest::providerTestOn4xx()

File

core/tests/Drupal/Tests/Core/EventSubscriber/ExceptionJsonSubscriberTest.php, line 42

Class

ExceptionJsonSubscriberTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21EventSubscriber%21ExceptionJsonSubscriber.php/class/ExceptionJsonSubscriber/9" title="Default handling for JSON errors." class="local">\Drupal\Core\EventSubscriber\ExceptionJsonSubscriber</a> @group EventSubscriber

Namespace

Drupal\Tests\Core\EventSubscriber

Code

public function providerTestOn4xx() {
    return [
        'uncacheable exception' => [
            new MethodNotAllowedHttpException([
                'POST',
                'PUT',
            ], 'test message'),
            JsonResponse::class,
        ],
        'cacheable exception' => [
            new CacheableMethodNotAllowedHttpException((new CacheableMetadata())->setCacheContexts([
                'route',
            ]), [
                'POST',
                'PUT',
            ], 'test message'),
            CacheableJsonResponse::class,
        ],
    ];
}

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