You are here

public function OptionsRequestSubscriberTest::providerTestOnRequestWithOptionsRequest in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\OptionsRequestSubscriberTest::providerTestOnRequestWithOptionsRequest()
  2. 9 core/tests/Drupal/Tests/Core/EventSubscriber/OptionsRequestSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\OptionsRequestSubscriberTest::providerTestOnRequestWithOptionsRequest()

File

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

Class

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

Namespace

Drupal\Tests\Core\EventSubscriber

Code

public 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;
}