Lemon\RestBundle\Tests\Controller\ResourceControllerTest::test500 PHP Method

test500() public method

public test500 ( )
    public function test500()
    {
        /** @var \Symfony\Component\EventDispatcher\EventDispatcher$eventDispatcher */
        $eventDispatcher = $this->container->get('lemon_rest.event_dispatcher');
        $eventDispatcher->addListener(RestEvents::PRE_CREATE, function () {
            throw new \RuntimeException("Proceed no further!");
        });
        $request = $this->makeRequest('POST', '/person', json_encode(array('name' => 'Stan Lemon', 'created' => date(DATE_ISO8601))));
        /** @var \Symfony\Component\HttpFoundation\Response $response */
        $response = $this->controller->postAction($request, 'person');
        $this->assertEquals(500, $response->getStatusCode());
        $data = json_decode($response->getContent());
        $this->assertEquals("Proceed no further!", $data->message);
    }