Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sebastianbergmann/phpunit-example-extension
Example of an extension for PHPUnit
https://github.com/sebastianbergmann/phpunit-example-extension
phpunit
Last synced: 5 days ago
JSON representation
Example of an extension for PHPUnit
- Host: GitHub
- URL: https://github.com/sebastianbergmann/phpunit-example-extension
- Owner: sebastianbergmann
- License: other
- Archived: true
- Created: 2016-11-25T13:13:11.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2022-04-11T13:50:36.000Z (almost 3 years ago)
- Last Synced: 2024-11-14T17:47:04.023Z (2 months ago)
- Topics: phpunit
- Language: PHP
- Homepage: https://phpunit.de/
- Size: 20.5 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# PHPUnit Example Extension
Example of an extension for [PHPUnit](https://phpunit.de/).
## Installation
### Composer
If you use [Composer](https://getcomposer.org/) to manage the dependencies of your project then you can add the PHPUnit example extension as a development-time dependency to your project:
```
$ composer require --dev phpunit/example-extension
```### PHP Archive (PHAR)
If you use PHPUnit 5.7 (or later) from a [PHP Archive (PHAR)](https://php.net/phar) then you can download a PHAR of the PHPUnit example extension:
```
$ wget https://phar.phpunit.de/phpunit-example-extension.phar
```The example below shows how to configure PHPUnit to load all `*.phar` files found in a given directory (`tools/phpunit.d` in this example):
```xml
```
PHPUnit will only load a an extension PHAR if it provides valid manifest information in a `manifest.xml` file:
```xml
```
Of course, the extension to be loaded must also be compatible with the version of PHPUnit trying to load it. The extension provides the information required for this compatbility check in its manifest.
When verbose output is activated, PHPUnit will print loaded extension PHARs:
```
$ phpunit --verbose tests
PHPUnit 6.3.0 by Sebastian Bergmann and contributors.Runtime: PHP 7.1.8 with Xdebug 2.5.5
Configuration: /home/sb/example/phpunit.xml
Extension: phpunit/phpunit-example-extension 3.0.0. 1 / 1 (100%)
Time: 32 ms, Memory: 4.00MB
OK (1 test, 1 assertion)
```The `--no-extensions` commandline option can be used to suppress the loading of extensions from the directory configured using `extensionsDirectory`:
```
$ phpunit --no-extensions
PHP Fatal error: Trait 'PHPUnit\ExampleExtension\TestCaseTrait' not found in ...
```