function OptionsRequestSubscriberTest::providerTestOnRequestWithOptionsRequest

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\OptionsRequestSubscriberTest::providerTestOnRequestWithOptionsRequest()
  2. 8.9.x core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\OptionsRequestSubscriberTest::providerTestOnRequestWithOptionsRequest()
  3. 11.x core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\OptionsRequestSubscriberTest::providerTestOnRequestWithOptionsRequest()

File

core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php, line 77

Class

OptionsRequestSubscriberTest
@coversDefaultClass \Drupal\Core\EventSubscriber\OptionsRequestSubscriber @group EventSubscriber

Namespace

Drupal\Tests\Core\EventSubscriber

Code

public static function providerTestOnRequestWithOptionsRequest() {
    $data = [];
    foreach ([
        'GET',
        'POST',
        'PATCH',
        'PUT',
        'DELETE',
    ] as $method) {
        $collection = new RouteCollection();
        $collection->add('example.1', new Route('/example', [], [], [], '', [], [
            $method,
        ]));
        $data['one_route_' . $method] = [
            $collection,
            $method,
        ];
    }
    foreach ([
        'GET',
        'POST',
        'PATCH',
        'PUT',
        'DELETE',
    ] as $method_a) {
        foreach ([
            'GET',
            'POST',
            'PATCH',
            'PUT',
            'DELETE',
        ] as $method_b) {
            if ($method_a != $method_b) {
                $collection = new RouteCollection();
                $collection->add('example.1', new Route('/example', [], [], [], '', [], [
                    $method_a,
                    $method_b,
                ]));
                $data['one_route_' . $method_a . '_' . $method_b] = [
                    $collection,
                    $method_a . ', ' . $method_b,
                ];
            }
        }
    }
    foreach ([
        'GET',
        'POST',
        'PATCH',
        'PUT',
        'DELETE',
    ] as $method_a) {
        foreach ([
            'GET',
            'POST',
            'PATCH',
            'PUT',
            'DELETE',
        ] as $method_b) {
            foreach ([
                'GET',
                'POST',
                'PATCH',
                'PUT',
                'DELETE',
            ] as $method_c) {
                $collection = new RouteCollection();
                $collection->add('example.1', new Route('/example', [], [], [], '', [], [
                    $method_a,
                ]));
                $collection->add('example.2', new Route('/example', [], [], [], '', [], [
                    $method_a,
                    $method_b,
                ]));
                $collection->add('example.3', new Route('/example', [], [], [], '', [], [
                    $method_b,
                    $method_c,
                ]));
                $methods = array_unique([
                    $method_a,
                    $method_b,
                    $method_c,
                ]);
                $data['multiple_routes_' . $method_a . '_' . $method_b . '_' . $method_c] = [
                    $collection,
                    implode(', ', $methods),
                ];
            }
        }
    }
    return $data;
}

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