You are here

public function OptionsRequestSubscriberTest::testWithNonOptionRequest in Drupal 9

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

@covers ::onRequest

File

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

Class

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

Namespace

Drupal\Tests\Core\EventSubscriber

Code

public function testWithNonOptionRequest() {
  $kernel = $this
    ->prophesize(HttpKernelInterface::class);
  $request = Request::create('/example', 'GET');
  $route_provider = $this
    ->prophesize(RouteProviderInterface::class);
  $route_provider
    ->getRouteCollectionForRequest($request)
    ->shouldNotBeCalled();
  $subscriber = new OptionsRequestSubscriber($route_provider
    ->reveal());
  $event = new RequestEvent($kernel
    ->reveal(), $request, HttpKernelInterface::MASTER_REQUEST);
  $subscriber
    ->onRequest($event);
  $this
    ->assertFalse($event
    ->hasResponse());
}