Download the PHP package eliashaeussler/phpunit-attributes without Composer
On this page you can find all versions of the php package eliashaeussler/phpunit-attributes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eliashaeussler/phpunit-attributes
More information about eliashaeussler/phpunit-attributes
Files in eliashaeussler/phpunit-attributes
Package phpunit-attributes
Short Description Provides additional attributes for tests with PHPUnit
License GPL-3.0-or-later
Informations about the package phpunit-attributes
A Composer library with additional attributes to enhance testing with PHPUnit.
🔥 Installation
⚡ Usage
The library ships with a ready-to-use PHPUnit extension. It must be registered in your PHPUnit configuration file:
Some attributes can be configured with custom extension parameters. These must be added to the extension registration section like follows:
🎢 Attributes
The following attributes are shipped with this library:
#[RequiresClass]
#[RequiresPackage]
#[RequiresClass]
Scope: Class & Method level
With this attribute, tests or test cases can be marked as to be only executed if a certain class exists. The given class must be loadable by the current class loader (which normally is Composer's default class loader).
Configuration
By default, test cases requiring non-existent classes are skipped. However, this
behavior can be configured by using the handleMissingClasses
extension parameter.
If set to fail
, test cases with missing classes will fail (defaults to skip
):
Example
More examples
#### Require single class Class level: Method level: #### Require single class and provide custom message Class level: Method level: #### Require single class and define custom outcome behavior Class level: Method level: #### Require multiple classes Class level: Method level:#[RequiresPackage]
Scope: Class & Method level
This attribute can be used to define specific package requirements for single tests as well as complete test classes. A required package is expected to be installed via Composer. You can optionally define a version constraint and a custom message.
[!IMPORTANT] The attribute determines installed Composer packages from the build-time generated
InstalledVersions
class built by Composer. In order to properly read from this class , it's essential to include Composer's generated autoloader in your PHPUnit bootstrap script:You can also pass the script as command option:
phpunit --bootstrap vendor/autoload.php
Configuration
By default, test cases with unsatisfied requirements are skipped. However, this
behavior can be configured by using the handleUnsatisfiedPackageRequirements
extension parameter. If set to fail
, test cases with unsatisfied requirements
will fail (defaults to skip
):
Example
More examples
#### Require explicit Composer package Class level: Method level: #### Require any Composer package matching a given pattern Class level: Method level: #### Require Composer package with given version constraint Class level: Method level: #### Require Composer package and provide custom message Class level: Method level: #### Require Composer package and define custom outcome behavior Class level: Method level: #### Multiple requirements Class level: Method level:🧑💻 Contributing
Please have a look at CONTRIBUTING.md
.
⭐ License
This project is licensed under GNU General Public License 3.0 (or later).