OrnoTest\Route\DispatcherTest::testRestfulStrategyReturnsJsonResponseWhenHttpExceptionIsThrown PHP Method

testRestfulStrategyReturnsJsonResponseWhenHttpExceptionIsThrown() public method

Assert that a route using the Restful Strategy returns a json response when a http exception is thrown
    public function testRestfulStrategyReturnsJsonResponseWhenHttpExceptionIsThrown()
    {
        $controller = $this->getMock('SomeClass', ['someMethod']);
        $controller->expects($this->once())->method('someMethod')->will($this->throwException(new HttpException\ConflictException()));
        $container = $this->getMock('Orno\\Di\\Container');
        $container->expects($this->at(1))->method('get')->with($this->equalTo('SomeClass'))->will($this->returnValue($controller));
        $collection = new Route\RouteCollection($container);
        $collection->setStrategy(Route\RouteStrategyInterface::RESTFUL_STRATEGY);
        $collection->get('/route', 'SomeClass::someMethod');
        $dispatcher = $collection->getDispatcher();
        $response = $dispatcher->dispatch('GET', '/route');
        $this->assertInstanceOf('Orno\\Http\\JsonResponse', $response);
        $this->assertSame(409, $response->getStatusCode());
        $this->assertSame('{"status_code":409,"message":"Conflict"}', $response->getContent());
    }