1 ### Setup your environment for tests
3 The framework used is [PHPUnit](https://phpunit.de/); it can be installed with [Composer](https://getcomposer.org/), which is a dependency management tool.
9 - a system-wide version, e.g. installed through your distro's package manager (eg. `sudo apt install composer`)
10 - a local version, downloadable [here](https://getcomposer.org/download/). To update a local composer installation, run `php composer.phar self-update`
13 #### Install Shaarli dev dependencies
21 #### Install and enable Xdebug to generate PHPUnit coverage reports
23 See http://xdebug.org/docs/install
26 # for Debian-based distributions
27 $ aptitude install php5-xdebug
33 Then add the following line to `/etc/php/php.ini`:
35 zend_extension=xdebug.so
40 Run `make test` and ensure tests return `OK`. If tests return failures, refer to PHPUnit messages and fix your code/tests accordingly.
43 #### Test results and coverage
45 By default, PHPUnit will run all suitable tests found under the `tests` directory.
47 Each test has 3 possible outcomes:
50 - `F` - failure: the test was run but its results are invalid
51 - the code does not behave as expected
52 - dependencies to external elements: globals, session, cache...
53 - `E` - error: something went wrong and the tested code has crashed
54 - typos in the code, or in the test code
55 - dependencies to missing external elements
57 If Xdebug has been installed and activated, two coverage reports will be generated:
59 - a summary in the console
60 - a detailed HTML report with metrics for tested code
61 - to open it in a web browser: `firefox coverage/index.html &`
63 ### Executing specific tests
65 Add a [`@group`](https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.group) annotation in a test class or method comment:
69 * Netscape bookmark import
72 class BookmarkImportTest extends PHPUnit_Framework_TestCase
78 To run all tests annotated with `@group WIP`:
80 $ vendor/bin/phpunit --group WIP tests/