3 ### Setup your environment for tests
4 The framework used is [PHPUnit](https://phpunit.de/); it can be installed with [Composer](https://getcomposer.org/), which is a dependency management tool.[](.html)
6 Regarding Composer, you can either use:
7 * a system-wide version, e.g. installed through your distro's package manager
8 * a local version, downloadable [here](https://getcomposer.org/download/)[](.html)
17 $ php composer.phar self-update
18 $ php composer.phar install
19 $ php composer.phar update
22 #### Install Shaarli dev dependencies
28 #### Install and enable Xdebug to generate PHPUnit coverage reports
29 For Debian-based distros:
31 $ aptitude install php5-xdebug
38 Then add the following line to `/etc/php/php.ini`:
40 zend_extension=xdebug.so
44 Successful test suite:
51 PHPUnit 4.6.9 by Sebastian Bergmann and contributors.
53 Configuration read from /home/virtualtam/public_html/shaarli/phpunit.xml
55 ....................................
57 Time: 759 ms, Memory: 8.25Mb
59 OK (36 tests, 65 assertions)
62 Test suite with failures and errors:
68 PHPUnit 4.6.9 by Sebastian Bergmann and contributors.
70 Configuration read from /home/virtualtam/public_html/shaarli/phpunit.xml
72 E..FF...............................
74 Time: 802 ms, Memory: 8.25Mb
78 1) LinkDBTest::testConstructLoggedIn
79 Missing argument 2 for LinkDB::__construct(), called in /home/virtualtam/public_html/shaarli/tests/Link\
80 DBTest.php on line 79 and defined
82 /home/virtualtam/public_html/shaarli/application/LinkDB.php:58
83 /home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:79
87 There were 2 failures:
89 1) LinkDBTest::testCheckDBNew
90 Failed asserting that two strings are equal.
94 -'e3edea8ea7bb50be4bcb404df53fbb4546a7156e'
95 +'85eab0c610d4f68025f6ed6e6b6b5fabd4b55834'
97 /home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:121
99 2) LinkDBTest::testCheckDBLoad
100 Failed asserting that two strings are equal.
104 -'e3edea8ea7bb50be4bcb404df53fbb4546a7156e'
105 +'85eab0c610d4f68025f6ed6e6b6b5fabd4b55834'
107 /home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:133
110 Tests: 36, Assertions: 63, Errors: 1, Failures: 2.
113 #### Test results and coverage
114 By default, PHPUnit will run all suitable tests found under the `tests` directory.
116 Each test has 3 possible outcomes:
118 * `F` - failure: the test was run but its results are invalid
119 * the code does not behave as expected
120 * dependencies to external elements: globals, session, cache...
121 * `E` - error: something went wrong and the tested code has crashed
122 * typos in the code, or in the test code
123 * dependencies to missing external elements
125 If Xdebug has been installed and activated, two coverage reports will be generated:
126 * a summary in the console
127 * a detailed HTML report with metrics for tested code
128 * to open it in a web browser: `firefox coverage/index.html &`