Пример #1
0
 /**
  * Asserts that an exception is thrown when an incorrect strategy type is provided
  *
  * @return void
  */
 public function testExceptionIsThrownWhenWrongStrategyTypeProvided()
 {
     $this->setExpectedException('InvalidArgumentException');
     $router = new RouteCollection();
     $router->setStrategy('hello');
 }
Пример #2
0
 /**
  * Asserts that a 405 response is returned whilst using restful strategy
  *
  * @return void
  */
 public function testDispatcherHandles405CorrectlyOnRestfulStrategy()
 {
     $collection = new Route\RouteCollection();
     $collection->setStrategy(Route\RouteStrategyInterface::RESTFUL_STRATEGY);
     $collection->post('/route', 'handler');
     $collection->put('/route', 'handler');
     $collection->delete('/route', 'handler');
     $dispatcher = $collection->getDispatcher();
     $response = $dispatcher->dispatch('GET', '/route');
     $this->assertInstanceOf('Orno\\Http\\JsonResponse', $response);
     $this->assertSame('{"status_code":405,"message":"Method Not Allowed"}', $response->getContent());
     $this->assertSame(405, $response->getStatusCode());
     $this->assertTrue($response->headers->has('Allow'));
     $this->assertSame('POST, PUT, DELETE', $response->headers->get('Allow'));
 }