https://github.com/lloople/phpunit-extensions
📦 Some cool extensions for PHPUnit
https://github.com/lloople/phpunit-extensions
csv database log php php-package phpunit phpunit-extensions phpunit-package testing
Last synced: 18 days ago
JSON representation
📦 Some cool extensions for PHPUnit
- Host: GitHub
- URL: https://github.com/lloople/phpunit-extensions
- Owner: Lloople
- License: mit
- Created: 2020-01-04T12:09:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-09-12T21:24:09.000Z (over 1 year ago)
- Last Synced: 2025-03-26T17:21:18.369Z (about 1 month ago)
- Topics: csv, database, log, php, php-package, phpunit, phpunit-extensions, phpunit-package, testing
- Language: PHP
- Homepage:
- Size: 34.2 KB
- Stars: 37
- Watchers: 1
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PHPUnit Extensions
[](https://packagist.org/packages/lloople/phpunit-extensions)
[](https://travis-ci.org/lloople/phpunit-extensions)
[](https://scrutinizer-ci.com/g/lloople/phpunit-extensions)
[](https://packagist.org/packages/lloople/phpunit-extensions)
[](https://plant.treeware.earth/Lloople/phpunit-extensions)This package provides you a few useful extensions for your testsuite in an effort to improve your code.
## Installation
You can install the package via composer:
```bash
composer require lloople/phpunit-extensions --dev
```Add the Extension to your `phpunit.xml` file:
```xml
```
## Extensions
### Console
Output the slowest tests on the console.
```xml
```
```
Showing the top 5 slowest tests:
543 ms: Tests\Feature\ProfileTest::can_upload_new_profile_image
26 ms: Tests\Feature\ProfileTest::can_visit_profile_page
25 ms: Tests\Feature\ProfileTest::throws_validation_error_if_password_not_match
```Default options are:
- rows: `5` (Report 5 tests max)
- min: `200` (Report tests slower than 200ms)### Csv
Write the tests in a CSV file ready for import.
```xml
```
Default options are:
- file: `phpunit_results.csv`
- rows: `null` (all the tests)
- min: `200`### Json
Write the tests in a JSON file ready for import.
```xml
```
Default options are:
- file: `phpunit_results.json`
- rows: `null` (all the tests)
- min: `200`### MySQL
Store the test name and the time into a MySQL database. It will override existing records
```xml
```
Default credentials are (as array):
- database: `phpunit_results`
- table: `default`
- username: `root`
- password: ``
- host: `127.0.0.1`
- rows: `null` (all the tests)
- min: `200`### SQLite
Store the test name and the time into a SQLite database. It will override existing records
```xml
```
Default credentials are (as array):
- database: `phpunit_results.db`
- table: `default`
- rows: `null` (all the tests)
- min: `200`## Arguments
To override the default configuration per extension, you need to use ``in your `phpunit.xml` file
```xml
phpunit_results_as_json.json
10
400
```
In the case of the MySQL and SQLite, which needs a database connection, configuration goes as array
```xml
my_phpunit_results
project1_test_results
homestead
secret
192.168.12.14
```
You don't need to override those credentials that already fit to your
usecase, since the class will merge your configuration with the default one## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
## Credits
- [David Llop](https://github.com/lloople)
- [All Contributors](../../contributors)## Treeware
You're free to use this package, but if it is really useful for you I would highly appreciate you [buying the world a tree](https://plant.treeware.earth/Lloople/phpunit-extensions).
It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to plant trees. If you contribute to [Treeware](https://plant.treeware.earth/Lloople/phpunit-extensions)'s forest you’ll be creating employment for local families and restoring wildlife habitats.
You can buy trees here [offset.earth/treeware](https://plant.treeware.earth/Lloople/phpunit-extensions)
Read more about Treeware at [treeware.earth](http://treeware.earth)