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 (which is as simple as writing a composer command, or downloading a .phar archive)
- Copy your existent YOURLS version into a new
YOURLS/
subdirectory, or clone the YOURLS repository:
$ git clone https://github.com/YOURLS/YOURLS.git
- Create an empty MySQL database and user. Do not use an exisiting database or you will lose data, guaranteed.
- Copy
yourls-tests-config-sample.php
toyourls-tests-config.php
, edit it and include your database name, user and password. - In that same directory, run the tests:
$ phpunit
Hopefully you should see something like the following appear:
PHPUnit 5.3.0 by Sebastian Bergmann and contributors.
Configuration read from /home/your/test/dir/tests/phpunit-travis.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)
-
When run locally (as opposed to when in the Travis-CI environment) the test script will start by dropping all tables in the selected database. Again, do not use an existing database.
-
Test cases live in the
tests/
subdirectory. All files in that directory will be included by default.
PHPUnit will initialize and install a complete running copy of YOURLS each time it is run. -
PHPUnit supports both
phpunit.xml
andphpunit.xml.dist
, wherephpunit.xml
has higher priority: if you want to specify your own settings, copyphpunit.xml.dist
tophpunit.xml
and edit that file.