Setup Symfony env to be used by unit tests?

Hey @SolarUltima,

In accordance with Symfony it seems like you’re calling the wrong thing from what I’ve read. In particular and in most cases the createClient() method of the WebTestCase calls the bootKernel() method from the KernelTestCase not the other way around, which in turn calls createKernel(). In createKernel() there is the following code which determines which environment the kernel should be booted in, as follows:

if (isset($options['environment'])) {
    $env = $options['environment'];
} elseif (isset($_ENV['APP_ENV'])) {
    $env = $_ENV['APP_ENV'];
} elseif (isset($_SERVER['APP_ENV'])) {
    $env = $_SERVER['APP_ENV'];
} else {
    $env = 'test';
}

In your case exporting the APP_ENV variable in your config_travis.yml, file and then setting it to travis (you can enforce this as well if you still are having problems, or reverts back - I have seen this before). That my possible solution and it should solve it. If it doesn’t please post back and I will gladly help you fix it.

2 Likes