https://github.com/imjoehaines/flowder-phpunit
A PHPUnit Listener for Flowder
https://github.com/imjoehaines/flowder-phpunit
fixture-loading fixtures flowder phpunit phpunit-listener testing
Last synced: 29 days ago
JSON representation
A PHPUnit Listener for Flowder
- Host: GitHub
- URL: https://github.com/imjoehaines/flowder-phpunit
- Owner: imjoehaines
- License: unlicense
- Created: 2017-03-22T21:45:21.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-27T09:16:19.000Z (over 6 years ago)
- Last Synced: 2025-04-01T20:53:55.571Z (about 1 month ago)
- Topics: fixture-loading, fixtures, flowder, phpunit, phpunit-listener, testing
- Language: PHP
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flowder PHPUnit [](https://packagist.org/packages/imjoehaines/flowder-phpunit) [](https://travis-ci.org/imjoehaines/flowder-phpunit) [](https://codecov.io/gh/imjoehaines/flowder-phpunit)
**Flowder PHPUnit** is a PHPUnit Test Listener for integrating the [Flowder](https://github.com/imjoehaines/flowder) fixture loader into PHPUnit test suites.
## Usage
1. Install Flowder PHPUnit as a development dependency through [Composer](https://getcomposer.org/)
```sh
$ composer install imjoehaines/flowder-phpunit --dev
```2. Enable Flowder PHPUnit as a test listener in your `phpunit.xml` file ([PHPUnit documentation](https://phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.test-listeners))
```xml
```3. Bootstrap Flowder PHPUnit by calling `FlowderListener::bootsrap` in your PHPUnit `bootstrap.php` file, passing in an instance of `\Imjoehaines\Flowder\Flowder` (see the [Flowder documentation](https://github.com/imjoehaines/flowder) for more information).
This is only necessary until [PHPUnit #1873](https://github.com/sebastianbergmann/phpunit/issues/1873) is fixed. After this, you can configure Flowder PHPUnit through your `phpunit.xml` file instead.
A simple SQLite example might look like this:
```php
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);FlowderListener::bootstrap(
__DIR__ . '/_data/example.php',
new PhpFileLoader(),
new SqliteTruncator($db),
new SqlitePersister($db)
);
```4. That's it! Before any test file runs, Flowder will load your fixture data for you