<li><aclass="toctree-l4"href="#install-shaarli-dev-dependencies">Install Shaarli dev dependencies</a></li>
<li><aclass="toctree-l4"href="#install-and-enable-xdebug-to-generate-phpunit-coverage-reports">Install and enable Xdebug to generate PHPUnit coverage reports</a></li>
<li><aclass="toctree-l4"href="#run-unit-tests">Run unit tests</a></li>
<li><aclass="toctree-l4"href="#test-results-and-coverage">Test results and coverage</a></li>
</ul>
<liclass="toctree-l3"><ahref="#executing-specific-tests">Executing specific tests</a></li>
</ul>
</li>
</ul>
</li>
<liclass="toctree-l1">
<spanclass="caption-text">About</span>
<ulclass="subnav">
<liclass="">
<aclass=""href="../FAQ/">FAQ</a>
</li>
<liclass="">
<aclass=""href="../Community-&-Related-software/">Community & Related software</a>
<h3id="setup-your-environment-for-tests">Setup your environment for tests</h3>
<p>The framework used is <ahref="https://phpunit.de/">PHPUnit</a>; it can be installed with <ahref="https://getcomposer.org/">Composer</a>, which is a dependency management tool.</p>
<p>Regarding Composer, you can either use:
<em> a system-wide version, e.g. installed through your distro's package manager
</em> a local version, downloadable <ahref="https://getcomposer.org/download/">here</a></p>
<h4id="sample-usage">Sample usage</h4>
<pre><codeclass="bash"># system-wide version
$ composer install
$ composer update
# local version
$ php composer.phar self-update
$ php composer.phar install
$ php composer.phar update
</code></pre>
<h4id="install-shaarli-dev-dependencies">Install Shaarli dev dependencies</h4>
<pre><codeclass="bash">$ cd /path/to/shaarli
$ composer update
</code></pre>
<h4id="install-and-enable-xdebug-to-generate-phpunit-coverage-reports">Install and enable Xdebug to generate PHPUnit coverage reports</h4>
<h4id="test-results-and-coverage">Test results and coverage</h4>
<p>By default, PHPUnit will run all suitable tests found under the <code>tests</code> directory.</p>
<p>Each test has 3 possible outcomes:
<em><code>.</code> - success
</em><code>F</code> - failure: the test was run but its results are invalid
* the code does not behave as expected
* dependencies to external elements: globals, session, cache...
* <code>E</code> - error: something went wrong and the tested code has crashed
* typos in the code, or in the test code
* dependencies to missing external elements</p>
<p>If Xdebug has been installed and activated, two coverage reports will be generated:
<em> a summary in the console
</em> a detailed HTML report with metrics for tested code
* to open it in a web browser: <code>firefox coverage/index.html &</code></p>
<h3id="executing-specific-tests">Executing specific tests</h3>
<p>Add a <ahref="https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.group"><code>@group</code></a> annotation in a test class or method comment:</p>
<pre><codeclass="php">/**
* Netscape bookmark import
* @group WIP
*/
class BookmarkImportTest extends PHPUnit_Framework_TestCase
{
[...]
}
</code></pre>
<p>To run all tests annotated with <code>@group WIP</code>:</p>
Built with <ahref="http://www.mkdocs.org">MkDocs</a> using a <ahref="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.