lundi 16 avril 2018

Environment variables in testing Symfony 4

I have config in services.yml

parameters:
   locale: 'en'
   uri: '%env(resolve:DEV_ENV_URI)%'

But when I execute tests, where I have used this parameter like

public function setUp()
{
    $this->client = static::createClient();

    static::bootKernel();

    $this->container = static::$kernel->getContainer();

    $this->guzzle = new Client(
        [
            'base_uri' => $this->container->getParameter('uri'),
            'verify' => false
        ]
    );
}

I have got error

Environment variable not found: "DEV_ENV_URI".

.env looks:

APP_ENV=test

DEV_ENV_URI=http://0.0.0.0:8000/

In dev mod during requests everything is great, but when I run test from console environment is not working.

Maybe you can suggest any other idea how to solve problem with establishing base uri for testing reason?

Thanks a lot for any idea!

Aucun commentaire:

Enregistrer un commentaire