My folder structure:
tests/
Controller/
Library/
Model/
Seeds/
bootstrap.php
phpunit.xml
I have an env.php file that defines some variables like so:
define('TESTING',true);
but in my test files:
$this->assertTrue(defined(TESTING));
ends up being false.
My phpunit.xml file:
<?xml version="1.0" ?>
<document>
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
processIsolation="true"
bootstrap="./bootstrap.php"
>
<testsuites>
<testsuite name="Main">
<directory>./</directory>
</testsuite>
<testsuite name="Library">
<directory>./Library/</directory>
</testsuite>
<testsuite name="Model">
<directory>./Model/</directory>
</testsuite>
<testsuite name="Controller">
<directory>./Controller/</directory>
</testsuite>
</testsuites>
</phpunit>
</document>
My bootstrap.php file requires my env.php file. So, why are the environment variables not accessible in my tests? I don't want to define all of my environment variables in my phpunit.xml file, since they are already defined in my env.php (DRY - right? ;) I have also tried using getenv(TESTING);
with no success.
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire