function ExceptionJsonSubscriberTest::providerTestOn4xx

Same name in other branches
  1. 9 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 \Drupal\Core\EventSubscriber\ExceptionJsonSubscriber @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.