Answer the question
In order to leave comments, you need to log in
PHPUnit: Why doesn't PHP get ENV variable from phpunit.xml?
I fasten testing for PHP code.
I check in PhpStorm IDE. The tests are working.
But I can't pass a variable from phpunit.xml to php.
Here is the content of phpunit.xml:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Tests">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<php>
<env name="UNIT_TEST" value="true" />
</php>
</phpunit>
<?php
define('APP_DIR', __DIR__);
define('BASE_DIR', dirname(APP_DIR));
define('CONFIGS_DIR', APP_DIR . '/configs');
define('VENDOR_DIR', BASE_DIR . '/vendor');
define('CACHE_DIR', BASE_DIR . '/cache');
var_dump(getenv('UNIT_TEST')); //return FALSE
var_dump($_ENV['UNIT_TEST']); //return NULL
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question