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 show warnings in PHPUnit?
- How to mock a method with different arguments in PHPUnit?
- How to run all PHPUnit tests?
- How to install PHPUnit with a PHAR file?
- How to run tests in parallel with PHPUnit?
- How to order tests with PHPUnit?
- How to use the PHPUnit Framework TestCase?
- How to mock a static method with PHPUnit?
- How to use a listener with PHPUnit?
See more codes...