phpunitHow to set environment variables for PHPUnit?
Environment variables can be set for PHPUnit by using the phpunit.xml
configuration file.
<phpunit>
<php>
<env name="VARIABLE_NAME" value="VARIABLE_VALUE"/>
</php>
</phpunit>
The above code block sets the environment variable VARIABLE_NAME
to VARIABLE_VALUE
.
<phpunit>
: This is the root element of the configuration file.<php>
: This element contains configuration directives for PHP.<env>
: This element sets environment variables.name
: This attribute sets the name of the environment variable.value
: This attribute sets the value of the environment variable.
Helpful links
More of Phpunit
- How to skip a PHPUnit test?
- How to run tests in parallel with PHPUnit?
- How to use hooks in PHPUnit?
- What are PHPUnit required extensions
- How to use the PHPUnit Framework TestCase?
- How to run PHPUnit in quiet mode?
- How to show warnings in PHPUnit?
- How to load fixtures with PHPUnit?
- How to use a listener with PHPUnit?
- How to stop PHPUnit on failure?
See more codes...