Files to enable unit testing Serendipity plugins using PHPUnit.
This has been tested with
- PHP 5.3.6, 5.5.3
- Serendipity 1.7-alpha1, 2.0-beta4
- PHPUnit 3.6.12, 3.7.24
- An active PSO_SQLITE PDO driver for PHP
Clone this repository into the S9Y_ROOT/tests/plugins
directory
git clone https://github.com/mattsches/s9y-plugins-phpunit tests/plugins
.
Copy phpunit.xml.dist
to phpunit.xml
(and edit if needed).
Unit tests go into a tests
directory under each plugin directory and should have the name of the plugin, e.g. S9Y_ROOT/plugins/serendipity_event_foobar/tests/foobarTest.php
. There is an example file in the example
directory of this repository.
You can run your unit tests from the Serendipity root directory:
phpunit -c tests/plugins/phpunit.xml plugins/serendipity_event_foobar/tests/foobarTest.php
or simply
phpunit -c tests/plugins/phpunit.xml
to run all plugin unit tests.
You can also set up your IDE to run phpunit tests, e.g. in PhpStorm use the following in Project Settings > PHP > PHPUnit > Test Runner:
- Use configuration file:
/path/to/tests/plugins/phpunit.xml
- Use bootstrap file:
/path/to/tests/plugins/bootstrap.php