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. 8.9.x 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 44

Class

ExceptionJsonSubscriberTest
@coversDefaultClass \Drupal\Core\EventSubscriber\ExceptionJsonSubscriber @group EventSubscriber

Namespace

Drupal\Tests\Core\EventSubscriber

Code

public static 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.