Example #1
0
 /**
  * @covers Respect\Rest\Router::handleOptionsRequest
  * @runInSeparateProcess
  */
 public function testOptionsRequestShouldBeDispatchedToCorrectOptionsHandler()
 {
     // arrange
     $router = new Router();
     $router->get('/asian', 'GET: Asian Food!');
     $router->options('/asian', 'OPTIONS: Asian Food!');
     $router->post('/asian', 'POST: Asian Food!');
     // act
     $response = (string) $router->dispatch('OPTIONS', '/asian')->response();
     // assert
     $this->assertContains('Allow: GET, OPTIONS, POST', xdebug_get_headers(), 'There should be a sent Allow header with all methods for the handler that match this request.');
     $this->assertEquals('OPTIONS: Asian Food!', $response, 'OPTIONS request should call the correct custom OPTIONS handler.');
 }