0

I started to explore symfony3 and after install I run the provided functional test via

phpunit

on the terminal, but I get the error:

1) Tests\AppBundle\Controller\DefaultControllerTest::testIndex
Failed asserting that 500 matches expected 200.

Hitting the page via browsers works.

What needs to be changed in settings to have this test pass?

k0pernikus
  • 60,309
  • 67
  • 216
  • 347
fefe
  • 8,755
  • 27
  • 104
  • 180
  • 2
    check in the `var/log/test.log` files for further details. – Matteo Jun 17 '16 at 19:03
  • 1
    cool thanks now makes sense! – fefe Jun 17 '16 at 19:23
  • hi @fefe have you solved? – Matteo Jun 17 '16 at 19:53
  • yes I had previously added FOSUserBundle but not configured and this is what I got in test.log `request.CRITICAL: Uncaught PHP Exception Symfony\Component\Config\Exception\FileLoaderLoadException: "Bundle "FOSUserBundle" does not exist or it is not enabled. `. Thanks for the tip! – fefe Jun 17 '16 at 20:47
  • 1
    Sidenote about wording: Even though you run the tests via phpunit, it's not a unit test but a functional test as you test the functionality of the site via a php browser, and not the output of methods for a certain input. [You may want to read this answer](http://stackoverflow.com/a/2741845/457268) – k0pernikus Jun 19 '16 at 20:08

1 Answers1

0

The error refers to this particular line:

$this->assertEquals(200, $client->getResponse()->getStatusCode());

It is expecting an html response code of "200" but instead you are getting '500', which is "Internal Server Error".

Alvin Bunk
  • 7,621
  • 3
  • 29
  • 45
  • I realized that but why is dropping that? as I said if I access via bowser is okay – fefe Jun 17 '16 at 18:40
  • 1
    pass response's content as third argument to the assertion (the message) to get the page output on failed test: `$this->assertEquals(200, $client->getResponse()->getStatusCode(), $client->getResponse()->getContent());` – Jakub Zalas Jun 17 '16 at 19:32