I have a config in services.yaml
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 the following error:
Environment variable not found: "DEV_ENV_URI".
Here is my .env
:
APP_ENV=test
DEV_ENV_URI=http://0.0.0.0:8000/
In dev environment during requests everything is great, but when I run tests from the terminal, the environment is not working.
Maybe you can suggest any other idea, how to solve the problem with establishing base URI for testing reason?
Thanks a lot for any idea!
I think the proper way to fix this is to use the configuration file of PHPUnit:
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
<env name="KERNEL_CLASS" value="App\Kernel" />
<env name="APP_ENV" value="test" />
<env name="APP_DEBUG" value="1" />
<env name="APP_SECRET" value="s$cretf0rt3st" />
</php>
</phpunit>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With