Unit Tests for YOURLS
This is the unit test suite for YOURLS: a collection of hundreds of tests to make sure that whenever something in YOURLS is added, changed or removed, everything still works under all the supported PHP versions.
If you want to run tests locally:
- Install PHPUnit.
composer -d tests/ install
- Create an empty MySQL database and user. Do not use an exisiting database or you will lose data, guaranteed.
- Copy
<YOURLS_ROOT>tests/data/config/yourls-tests-config-sample.phpto<YOURLS_ROOT>/tests/yourls-tests-config.phpand edit it to match your setup.cp tests/data/config/yourls-tests-config-sample.php tests/yourls-tests-config.php
- In YOURLS root directory, you can now run the shell command:
composer -d tests/ run test -- --configuration=../phpunit.xml.dist ..
Hopefully you should see something like the following appear:
YOURLS installed, starting PHPUnit
PHPUnit by Sebastian Bergmann and contributors.
Configuration: ...\phpunit.xml.dist
............................................................... 63 / 519 ( 12%)
............................................................... 126 / 519 ( 24%)
............................................................... 189 / 519 ( 36%)
............................................................... 252 / 519 ( 48%)
............................................................... 315 / 519 ( 60%)
............................................................... 378 / 519 ( 72%)
............................................................... 441 / 519 ( 84%)
............................................................... 504 / 519 ( 97%)
............... 519 / 519 (100%)
Time: 6.06 seconds, Memory: 24.25Mb
OK (519 tests, 1123 assertions)
You can elect to run only selected groups of tests, eg:
$ phpunit --group formattingPHPUnit supports both phpunit.xml and phpunit.xml.dist, where phpunit.xml has higher priority:
if you want to specify your own settings, copy phpunit.xml.dist to phpunit.xml and edit that file.