2 ### 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.
5 Regarding Composer, you can either use:
6 * a system-wide version, e.g. installed through your distro's package manager
7 * a local version, downloadable [here](https://getcomposer.org/download/)
16 $ php composer.phar self-update
17 $ php composer.phar install
18 $ php composer.phar update
21 #### Install Shaarli dev dependencies
27 #### Install and enable Xdebug to generate PHPUnit coverage reports
28 For Debian-based distros:
30 $ aptitude install php5-xdebug
37 Then add the following line to `/etc/php/php.ini`:
39 zend_extension=xdebug.so
43 Successful test suite:
50 PHPUnit 4.6.9 by Sebastian Bergmann and contributors.
52 Configuration read from /home/virtualtam/public_html/shaarli/phpunit.xml
54 ....................................
56 Time: 759 ms, Memory: 8.25Mb
58 OK (36 tests, 65 assertions)
61 Test suite with failures and errors:
67 PHPUnit 4.6.9 by Sebastian Bergmann and contributors.
69 Configuration read from /home/virtualtam/public_html/shaarli/phpunit.xml
71 E..FF...............................
73 Time: 802 ms, Memory: 8.25Mb
77 1) LinkDBTest::testConstructLoggedIn
78 Missing argument 2 for LinkDB::__construct(), called in /home/virtualtam/public_html/shaarli/tests/Link\
79 DBTest.php on line 79 and defined
81 /home/virtualtam/public_html/shaarli/application/LinkDB.php:58
82 /home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:79
86 There were 2 failures:
88 1) LinkDBTest::testCheckDBNew
89 Failed asserting that two strings are equal.
93 -'e3edea8ea7bb50be4bcb404df53fbb4546a7156e'
94 +'85eab0c610d4f68025f6ed6e6b6b5fabd4b55834'
96 /home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:121
98 2) LinkDBTest::testCheckDBLoad
99 Failed asserting that two strings are equal.
103 -'e3edea8ea7bb50be4bcb404df53fbb4546a7156e'
104 +'85eab0c610d4f68025f6ed6e6b6b5fabd4b55834'
106 /home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:133
109 Tests: 36, Assertions: 63, Errors: 1, Failures: 2.
112 #### Test results and coverage
113 By default, PHPUnit will run all suitable tests found under the `tests` directory.
115 Each test has 3 possible outcomes:
117 * `F` - failure: the test was run but its results are invalid
118 * the code does not behave as expected
119 * dependencies to external elements: globals, session, cache...
120 * `E` - error: something went wrong and the tested code has crashed
121 * typos in the code, or in the test code
122 * dependencies to missing external elements
124 If Xdebug has been installed and activated, two coverage reports will be generated:
125 * a summary in the console
126 * a detailed HTML report with metrics for tested code
127 * to open it in a web browser: `firefox coverage/index.html &`