Download the PHP package zalas/phpunit-globals without Composer
On this page you can find all versions of the php package zalas/phpunit-globals. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zalas/phpunit-globals
More information about zalas/phpunit-globals
Files in zalas/phpunit-globals
Package phpunit-globals
Short Description Allows to use attributes to define global variables in PHPUnit test cases.
License MIT
Informations about the package phpunit-globals
PHPUnit Globals
Allows to use attributes to define global variables in PHPUnit test cases.
Supported attributes:
#[Env]
for$_ENV
#[Server]
for$_SERVER
#[Putenv]
forputenv()
Annotations were previously supported up until v3.5.0 (inclusive). Annotation support is complete, so if you plan on using them keep using v3.5 of this package.
Global variables are set before each test case is executed,
and brought to the original state after each test case has finished.
The same applies to putenv()
/getenv()
calls.
Installation
Composer
Phar
The extension is also distributed as a PHAR, which can be downloaded from the most recent Github Release.
Put the extension in your PHPUnit extensions directory.
Remember to instruct PHPUnit to load extensions in your phpunit.xml
using the extensionsDirectory
attribute:
Usage
Enable the globals attribute extension in your PHPUnit configuration:
Make sure the AttributeExtension
is registered before any other extensions that might depend on global variables.
Global variables can now be defined in attributes:
It's also possible to mark an attribute with unset so it will not be present in any of the global variables:
Updating to PHPUnit 10
When updating from a previous version of this extension dedicated to work with PHPUnit 9,
replace the extension registration in phpunit.xml
:
with:
Contributing
Please read the Contributing guide to learn about contributing to this project. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
All versions of phpunit-globals with dependencies
phpunit/phpunit Version ^10.0 || ^11.0 || ^12.0