diff options
Diffstat (limited to 'doc/html/Unit-tests/index.html')
-rw-r--r-- | doc/html/Unit-tests/index.html | 480 |
1 files changed, 0 insertions, 480 deletions
diff --git a/doc/html/Unit-tests/index.html b/doc/html/Unit-tests/index.html deleted file mode 100644 index ebc92beb..00000000 --- a/doc/html/Unit-tests/index.html +++ /dev/null | |||
@@ -1,480 +0,0 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> | ||
3 | <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> | ||
4 | <head> | ||
5 | <meta charset="utf-8"> | ||
6 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
7 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
8 | |||
9 | |||
10 | <link rel="shortcut icon" href="../img/favicon.ico"> | ||
11 | <title>Unit tests - Shaarli Documentation</title> | ||
12 | <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'> | ||
13 | |||
14 | <link rel="stylesheet" href="../css/theme.css" type="text/css" /> | ||
15 | <link rel="stylesheet" href="../css/theme_extra.css" type="text/css" /> | ||
16 | <link rel="stylesheet" href="../css/highlight.css"> | ||
17 | <link href="../github-markdown.css" rel="stylesheet"> | ||
18 | |||
19 | <script> | ||
20 | // Current page data | ||
21 | var mkdocs_page_name = "Unit tests"; | ||
22 | var mkdocs_page_input_path = "Unit-tests.md"; | ||
23 | var mkdocs_page_url = "/Unit-tests/"; | ||
24 | </script> | ||
25 | |||
26 | <script src="../js/jquery-2.1.1.min.js"></script> | ||
27 | <script src="../js/modernizr-2.8.3.min.js"></script> | ||
28 | <script type="text/javascript" src="../js/highlight.pack.js"></script> | ||
29 | |||
30 | </head> | ||
31 | |||
32 | <body class="wy-body-for-nav" role="document"> | ||
33 | |||
34 | <div class="wy-grid-for-nav"> | ||
35 | |||
36 | |||
37 | <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav"> | ||
38 | <div class="wy-side-nav-search"> | ||
39 | <a href=".." class="icon icon-home"> Shaarli Documentation</a> | ||
40 | <div role="search"> | ||
41 | <form id ="rtd-search-form" class="wy-form" action="../search.html" method="get"> | ||
42 | <input type="text" name="q" placeholder="Search docs" /> | ||
43 | </form> | ||
44 | </div> | ||
45 | </div> | ||
46 | |||
47 | <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> | ||
48 | <ul class="current"> | ||
49 | |||
50 | |||
51 | <li class="toctree-l1"> | ||
52 | |||
53 | <a class="" href="..">Home</a> | ||
54 | </li> | ||
55 | |||
56 | <li class="toctree-l1"> | ||
57 | |||
58 | <span class="caption-text">Setup</span> | ||
59 | <ul class="subnav"> | ||
60 | <li class=""> | ||
61 | |||
62 | <a class="" href="../Download-and-Installation/">Download and Installation</a> | ||
63 | </li> | ||
64 | <li class=""> | ||
65 | |||
66 | <a class="" href="../Upgrade-and-migration/">Upgrade and migration</a> | ||
67 | </li> | ||
68 | <li class=""> | ||
69 | |||
70 | <a class="" href="../Server-requirements/">Server requirements</a> | ||
71 | </li> | ||
72 | <li class=""> | ||
73 | |||
74 | <a class="" href="../Server-configuration/">Server configuration</a> | ||
75 | </li> | ||
76 | <li class=""> | ||
77 | |||
78 | <a class="" href="../Server-security/">Server security</a> | ||
79 | </li> | ||
80 | <li class=""> | ||
81 | |||
82 | <a class="" href="../Shaarli-configuration/">Shaarli configuration</a> | ||
83 | </li> | ||
84 | <li class=""> | ||
85 | |||
86 | <a class="" href="../Plugins/">Plugins</a> | ||
87 | </li> | ||
88 | </ul> | ||
89 | </li> | ||
90 | |||
91 | <li class="toctree-l1"> | ||
92 | |||
93 | <span class="caption-text">Docker</span> | ||
94 | <ul class="subnav"> | ||
95 | <li class=""> | ||
96 | |||
97 | <a class="" href="../docker/docker-101/">Docker 101</a> | ||
98 | </li> | ||
99 | <li class=""> | ||
100 | |||
101 | <a class="" href="../docker/shaarli-images/">Shaarli images</a> | ||
102 | </li> | ||
103 | <li class=""> | ||
104 | |||
105 | <a class="" href="../docker/reverse-proxy-configuration/">Reverse proxy configuration</a> | ||
106 | </li> | ||
107 | <li class=""> | ||
108 | |||
109 | <a class="" href="../docker/resources/">Docker resources</a> | ||
110 | </li> | ||
111 | </ul> | ||
112 | </li> | ||
113 | |||
114 | <li class="toctree-l1"> | ||
115 | |||
116 | <span class="caption-text">Usage</span> | ||
117 | <ul class="subnav"> | ||
118 | <li class=""> | ||
119 | |||
120 | <a class="" href="../Features/">Features</a> | ||
121 | </li> | ||
122 | <li class=""> | ||
123 | |||
124 | <a class="" href="../Bookmarklet/">Bookmarklet</a> | ||
125 | </li> | ||
126 | <li class=""> | ||
127 | |||
128 | <a class="" href="../Browsing-and-searching/">Browsing and searching</a> | ||
129 | </li> | ||
130 | <li class=""> | ||
131 | |||
132 | <a class="" href="../Firefox-share/">Firefox share</a> | ||
133 | </li> | ||
134 | <li class=""> | ||
135 | |||
136 | <a class="" href="../RSS-feeds/">RSS feeds</a> | ||
137 | </li> | ||
138 | <li class=""> | ||
139 | |||
140 | <a class="" href="../REST-API/">REST API</a> | ||
141 | </li> | ||
142 | </ul> | ||
143 | </li> | ||
144 | |||
145 | <li class="toctree-l1"> | ||
146 | |||
147 | <span class="caption-text">How To</span> | ||
148 | <ul class="subnav"> | ||
149 | <li class=""> | ||
150 | |||
151 | <a class="" href="../Backup,-restore,-import-and-export/">Backup, restore, import and export</a> | ||
152 | </li> | ||
153 | <li class=""> | ||
154 | |||
155 | <a class="" href="../Various-hacks/">Various hacks</a> | ||
156 | </li> | ||
157 | </ul> | ||
158 | </li> | ||
159 | |||
160 | <li class="toctree-l1"> | ||
161 | |||
162 | <a class="" href="../Troubleshooting/">Troubleshooting</a> | ||
163 | </li> | ||
164 | |||
165 | <li class="toctree-l1"> | ||
166 | |||
167 | <span class="caption-text">Development</span> | ||
168 | <ul class="subnav"> | ||
169 | <li class=""> | ||
170 | |||
171 | <a class="" href="../Development-guidelines/">Development guidelines</a> | ||
172 | </li> | ||
173 | <li class=""> | ||
174 | |||
175 | <a class="" href="../Continuous-integration-tools/">Continuous integration tools</a> | ||
176 | </li> | ||
177 | <li class=""> | ||
178 | |||
179 | <a class="" href="../GnuPG-signature/">GnuPG signature</a> | ||
180 | </li> | ||
181 | <li class=""> | ||
182 | |||
183 | <a class="" href="../Coding-guidelines/">Coding guidelines</a> | ||
184 | </li> | ||
185 | <li class=""> | ||
186 | |||
187 | <a class="" href="../Directory-structure/">Directory structure</a> | ||
188 | </li> | ||
189 | <li class=""> | ||
190 | |||
191 | <a class="" href="../3rd-party-libraries/">3rd party libraries</a> | ||
192 | </li> | ||
193 | <li class=""> | ||
194 | |||
195 | <a class="" href="../Plugin-System/">Plugin System</a> | ||
196 | </li> | ||
197 | <li class=""> | ||
198 | |||
199 | <a class="" href="../Release-Shaarli/">Release Shaarli</a> | ||
200 | </li> | ||
201 | <li class=""> | ||
202 | |||
203 | <a class="" href="../Versioning-and-Branches/">Versioning and Branches</a> | ||
204 | </li> | ||
205 | <li class=""> | ||
206 | |||
207 | <a class="" href="../Security/">Security</a> | ||
208 | </li> | ||
209 | <li class=""> | ||
210 | |||
211 | <a class="" href="../Static-analysis/">Static analysis</a> | ||
212 | </li> | ||
213 | <li class=""> | ||
214 | |||
215 | <a class="" href="../Theming/">Theming</a> | ||
216 | </li> | ||
217 | <li class=" current"> | ||
218 | |||
219 | <a class="current" href="./">Unit tests</a> | ||
220 | <ul class="subnav"> | ||
221 | |||
222 | <li class="toctree-l3"><a href="#setup-your-environment-for-tests">Setup your environment for tests</a></li> | ||
223 | |||
224 | <ul> | ||
225 | |||
226 | <li><a class="toctree-l4" href="#sample-usage">Sample usage</a></li> | ||
227 | |||
228 | <li><a class="toctree-l4" href="#install-shaarli-dev-dependencies">Install Shaarli dev dependencies</a></li> | ||
229 | |||
230 | <li><a class="toctree-l4" href="#install-and-enable-xdebug-to-generate-phpunit-coverage-reports">Install and enable Xdebug to generate PHPUnit coverage reports</a></li> | ||
231 | |||
232 | <li><a class="toctree-l4" href="#run-unit-tests">Run unit tests</a></li> | ||
233 | |||
234 | <li><a class="toctree-l4" href="#test-results-and-coverage">Test results and coverage</a></li> | ||
235 | |||
236 | </ul> | ||
237 | |||
238 | |||
239 | <li class="toctree-l3"><a href="#executing-specific-tests">Executing specific tests</a></li> | ||
240 | |||
241 | |||
242 | </ul> | ||
243 | </li> | ||
244 | </ul> | ||
245 | </li> | ||
246 | |||
247 | <li class="toctree-l1"> | ||
248 | |||
249 | <span class="caption-text">About</span> | ||
250 | <ul class="subnav"> | ||
251 | <li class=""> | ||
252 | |||
253 | <a class="" href="../FAQ/">FAQ</a> | ||
254 | </li> | ||
255 | <li class=""> | ||
256 | |||
257 | <a class="" href="../Community-&-Related-software/">Community & Related software</a> | ||
258 | </li> | ||
259 | </ul> | ||
260 | </li> | ||
261 | |||
262 | </ul> | ||
263 | </div> | ||
264 | | ||
265 | </nav> | ||
266 | |||
267 | <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> | ||
268 | |||
269 | |||
270 | <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> | ||
271 | <i data-toggle="wy-nav-top" class="fa fa-bars"></i> | ||
272 | <a href="..">Shaarli Documentation</a> | ||
273 | </nav> | ||
274 | |||
275 | |||
276 | <div class="wy-nav-content"> | ||
277 | <div class="rst-content"> | ||
278 | <div role="navigation" aria-label="breadcrumbs navigation"> | ||
279 | <ul class="wy-breadcrumbs"> | ||
280 | <li><a href="..">Docs</a> »</li> | ||
281 | |||
282 | |||
283 | |||
284 | <li>Development »</li> | ||
285 | |||
286 | |||
287 | |||
288 | <li>Unit tests</li> | ||
289 | <li class="wy-breadcrumbs-aside"> | ||
290 | |||
291 | <a href="https://github.com/shaarli/Shaarli/edit/master/docs/Unit-tests.md" | ||
292 | class="icon icon-github"> Edit on GitHub</a> | ||
293 | |||
294 | </li> | ||
295 | </ul> | ||
296 | <hr/> | ||
297 | </div> | ||
298 | <div role="main"> | ||
299 | <div class="section"> | ||
300 | |||
301 | <h3 id="setup-your-environment-for-tests">Setup your environment for tests</h3> | ||
302 | <p>The framework used is <a href="https://phpunit.de/">PHPUnit</a>; it can be installed with <a href="https://getcomposer.org/">Composer</a>, which is a dependency management tool.</p> | ||
303 | <p>Regarding Composer, you can either use: | ||
304 | <em> a system-wide version, e.g. installed through your distro's package manager | ||
305 | </em> a local version, downloadable <a href="https://getcomposer.org/download/">here</a></p> | ||
306 | <h4 id="sample-usage">Sample usage</h4> | ||
307 | <pre><code class="bash"># system-wide version | ||
308 | $ composer install | ||
309 | $ composer update | ||
310 | |||
311 | # local version | ||
312 | $ php composer.phar self-update | ||
313 | $ php composer.phar install | ||
314 | $ php composer.phar update | ||
315 | </code></pre> | ||
316 | |||
317 | <h4 id="install-shaarli-dev-dependencies">Install Shaarli dev dependencies</h4> | ||
318 | <pre><code class="bash">$ cd /path/to/shaarli | ||
319 | $ composer update | ||
320 | </code></pre> | ||
321 | |||
322 | <h4 id="install-and-enable-xdebug-to-generate-phpunit-coverage-reports">Install and enable Xdebug to generate PHPUnit coverage reports</h4> | ||
323 | <p>For Debian-based distros:</p> | ||
324 | <pre><code class="bash">$ aptitude install php5-xdebug | ||
325 | </code></pre> | ||
326 | |||
327 | <p>For ArchLinux:</p> | ||
328 | <pre><code class="bash">$ pacman -S xdebug | ||
329 | </code></pre> | ||
330 | |||
331 | <p>Then add the following line to <code>/etc/php/php.ini</code>:</p> | ||
332 | <pre><code class="ini">zend_extension=xdebug.so | ||
333 | </code></pre> | ||
334 | |||
335 | <h4 id="run-unit-tests">Run unit tests</h4> | ||
336 | <p>Successful test suite:</p> | ||
337 | <pre><code class="bash">$ make test | ||
338 | |||
339 | ------- | ||
340 | PHPUNIT | ||
341 | ------- | ||
342 | PHPUnit 4.6.9 by Sebastian Bergmann and contributors. | ||
343 | |||
344 | Configuration read from /home/virtualtam/public_html/shaarli/phpunit.xml | ||
345 | |||
346 | .................................... | ||
347 | |||
348 | Time: 759 ms, Memory: 8.25Mb | ||
349 | |||
350 | OK (36 tests, 65 assertions) | ||
351 | </code></pre> | ||
352 | |||
353 | <p>Test suite with failures and errors:</p> | ||
354 | <pre><code class="bash">$ make test | ||
355 | ------- | ||
356 | PHPUNIT | ||
357 | ------- | ||
358 | PHPUnit 4.6.9 by Sebastian Bergmann and contributors. | ||
359 | |||
360 | Configuration read from /home/virtualtam/public_html/shaarli/phpunit.xml | ||
361 | |||
362 | E..FF............................... | ||
363 | |||
364 | Time: 802 ms, Memory: 8.25Mb | ||
365 | |||
366 | There was 1 error: | ||
367 | |||
368 | 1) LinkDBTest::testConstructLoggedIn | ||
369 | Missing argument 2 for LinkDB::__construct(), called in /home/virtualtam/public_html/shaarli/tests/Link\ | ||
370 | DBTest.php on line 79 and defined | ||
371 | |||
372 | /home/virtualtam/public_html/shaarli/application/LinkDB.php:58 | ||
373 | /home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:79 | ||
374 | |||
375 | -- | ||
376 | |||
377 | There were 2 failures: | ||
378 | |||
379 | 1) LinkDBTest::testCheckDBNew | ||
380 | Failed asserting that two strings are equal. | ||
381 | --- Expected | ||
382 | +++ Actual | ||
383 | @@ @@ | ||
384 | -'e3edea8ea7bb50be4bcb404df53fbb4546a7156e' | ||
385 | +'85eab0c610d4f68025f6ed6e6b6b5fabd4b55834' | ||
386 | |||
387 | /home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:121 | ||
388 | |||
389 | 2) LinkDBTest::testCheckDBLoad | ||
390 | Failed asserting that two strings are equal. | ||
391 | --- Expected | ||
392 | +++ Actual | ||
393 | @@ @@ | ||
394 | -'e3edea8ea7bb50be4bcb404df53fbb4546a7156e' | ||
395 | +'85eab0c610d4f68025f6ed6e6b6b5fabd4b55834' | ||
396 | |||
397 | /home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:133 | ||
398 | |||
399 | FAILURES! | ||
400 | Tests: 36, Assertions: 63, Errors: 1, Failures: 2. | ||
401 | </code></pre> | ||
402 | |||
403 | <h4 id="test-results-and-coverage">Test results and coverage</h4> | ||
404 | <p>By default, PHPUnit will run all suitable tests found under the <code>tests</code> directory.</p> | ||
405 | <p>Each test has 3 possible outcomes: | ||
406 | <em> <code>.</code> - success | ||
407 | </em> <code>F</code> - failure: the test was run but its results are invalid | ||
408 | * the code does not behave as expected | ||
409 | * dependencies to external elements: globals, session, cache... | ||
410 | * <code>E</code> - error: something went wrong and the tested code has crashed | ||
411 | * typos in the code, or in the test code | ||
412 | * dependencies to missing external elements</p> | ||
413 | <p>If Xdebug has been installed and activated, two coverage reports will be generated: | ||
414 | <em> a summary in the console | ||
415 | </em> a detailed HTML report with metrics for tested code | ||
416 | * to open it in a web browser: <code>firefox coverage/index.html &</code></p> | ||
417 | <h3 id="executing-specific-tests">Executing specific tests</h3> | ||
418 | <p>Add a <a href="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> | ||
419 | <pre><code class="php">/** | ||
420 | * Netscape bookmark import | ||
421 | * @group WIP | ||
422 | */ | ||
423 | class BookmarkImportTest extends PHPUnit_Framework_TestCase | ||
424 | { | ||
425 | [...] | ||
426 | } | ||
427 | </code></pre> | ||
428 | |||
429 | <p>To run all tests annotated with <code>@group WIP</code>:</p> | ||
430 | <pre><code class="bash">$ vendor/bin/phpunit --group WIP tests/ | ||
431 | </code></pre> | ||
432 | |||
433 | </div> | ||
434 | </div> | ||
435 | <footer> | ||
436 | |||
437 | <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> | ||
438 | |||
439 | <a href="../FAQ/" class="btn btn-neutral float-right" title="FAQ">Next <span class="icon icon-circle-arrow-right"></span></a> | ||
440 | |||
441 | |||
442 | <a href="../Theming/" class="btn btn-neutral" title="Theming"><span class="icon icon-circle-arrow-left"></span> Previous</a> | ||
443 | |||
444 | </div> | ||
445 | |||
446 | |||
447 | <hr/> | ||
448 | |||
449 | <div role="contentinfo"> | ||
450 | <!-- Copyright etc --> | ||
451 | |||
452 | </div> | ||
453 | |||
454 | Built with <a href="http://www.mkdocs.org">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. | ||
455 | </footer> | ||
456 | |||
457 | </div> | ||
458 | </div> | ||
459 | |||
460 | </section> | ||
461 | |||
462 | </div> | ||
463 | |||
464 | <div class="rst-versions" role="note" style="cursor: pointer"> | ||
465 | <span class="rst-current-version" data-toggle="rst-current-version"> | ||
466 | |||
467 | <a href="https://github.com/shaarli/Shaarli" class="fa fa-github" style="float: left; color: #fcfcfc"> GitHub</a> | ||
468 | |||
469 | |||
470 | <span><a href="../Theming/" style="color: #fcfcfc;">« Previous</a></span> | ||
471 | |||
472 | |||
473 | <span style="margin-left: 15px"><a href="../FAQ/" style="color: #fcfcfc">Next »</a></span> | ||
474 | |||
475 | </span> | ||
476 | </div> | ||
477 | <script src="../js/theme.js"></script> | ||
478 | |||
479 | </body> | ||
480 | </html> | ||