A PHPUnit tool for YOURLS plugins.
The YOURLS test suite for plugins is a tool to test YOURLS plugins with standard PHPUnit tests.
This tool assumes basic knowledge of command line tools and of the PHPUnit framework.
Have a plugin with tests
See the short how-to guide about writing unit tests for YOURLS plugins.
Install the YOURLS test suite for plugins
In my-cool-plugin/
:
$ git clone https://github.com/YOURLS/YOURLS-test-suite-for-plugins test-suite
Install the YOURLS test suite and the testing database
$ bash test-suite/src/install-test-suite.sh <db-name> <db-user> <db-password> [db-host, default localhost] [YOURLS version, default master]
Examples :
$ bash test-suite/src/install-test-suite.sh yourlstest root ""
$ bash test-suite/src/install-test-suite.sh yourlstest mydbuser mydbpassword mysql.myserver.com:666 1.8.2
Run your plugin unit tests
Once you have written unit tests, run them :
$ phpunit -c ./test-suite/src/phpunit.xml
Expected result would be something like :
$ phpunit -c ./test-suite/src/phpunit.xml
YOURLS installed, starting PHPUnit
Plugin Loaded : My cool plugin by Joe (my-cool-plugin/plugin.php)
PHPUnit 9.5.2 by Sebastian Bergmann and contributors.
...... 3 / 3 (100%)
Time: 00:00.007, Memory: 22.00 MB
OK (3 tests, 6 assertions)
$
Automate tests
On a Github repository, set up Github actions to automatically run tests when your plugin code changes, or when there's a
new version of YOURLS available. See the workflows guide.
Free software. Do whatever the hell you want with it. YOURLS is released under the MIT license.