/**
  * @runInSeparateProcess
  */
 public function testHeaderOutputWithGeneratedRoutes()
 {
     $routes = [new ReadRoute(new Literal('/get/this'), new GetRequestHandler()), new ReadRoute(new Literal('/get/that'), new HeadRequestHandler()), new ReadRoute(new Literal('/get/this/again'), new GetRequestHandler())];
     $config = $this->getMockBuilder(ConfiguresIceHawk::class)->getMockForAbstractClass();
     $requestInfo = new RequestInfo(['REQUEST_METHOD' => 'OPTIONS', 'REQUEST_URI' => '/get/that']);
     $config->method('getRequestInfo')->willReturn($requestInfo);
     $config->method('getWriteRoutes')->willReturn([]);
     $config->method('getReadRoutes')->willReturn($this->getGeneratedRoutes($routes));
     $optionsRequestHandler = new OptionsRequestHandler($config, new EventPublisher());
     $optionsRequestHandler->handleRequest();
     $this->assertContains('Allow: HEAD', xdebug_get_headers());
 }
Example #2
0
 public function handleRequest()
 {
     $requestInfo = $this->config->getRequestInfo();
     if (in_array($requestInfo->getMethod(), HttpMethod::WRITE_METHODS)) {
         $requestHandler = new WriteRequestHandler($this->config, $this->eventPublisher);
         $requestHandler->handleRequest();
     } elseif (in_array($requestInfo->getMethod(), HttpMethod::READ_METHODS)) {
         $requestHandler = new ReadRequestHandler($this->config, $this->eventPublisher);
         $requestHandler->handleRequest();
     } elseif ($requestInfo->getMethod() == HttpMethod::OPTIONS) {
         $requestHandler = new OptionsRequestHandler($this->config, $this->eventPublisher);
         $requestHandler->handleRequest();
     } else {
         (new MethodNotImplemented($requestInfo->getMethod()))->respond();
     }
 }