I'm trying to functional test the HTTP status code for a certain request is 200
not 500
. I'm using Symfony2, and here's the code:
public function testIndex()
{
$client = static::createClient();
$crawler = $client->request('GET', "/");
$this->assertEquals('Ibw\JobeetBundle\Controller\JobController::indexAction', $client->getRequest()->attributes->get('_controller'));
$this->assertEquals(200 , $client->getResponse()->getStatusCode());
$this->assertEquals(0, $crawler->filter('.jobs td.position:contains("Expired")')->count());
}
And the result :
1) Ibw\JobeetBundle\Tests\Functional\JobControllerTest::testIndex Failed asserting that 500 matches expected 200.
When I access the route "/" manually through the browser it works just fine.
So what's wrong here ?