diff options
author | nodiscc <nodiscc@gmail.com> | 2017-01-26 18:52:54 +0100 |
---|---|---|
committer | nodiscc <nodiscc@gmail.com> | 2017-06-18 00:19:49 +0200 |
commit | 53ed6d7d1e678d7486337ce67a2f17b30bac21ac (patch) | |
tree | f8bef0164a70bd03d2b9781951c01bdd018f1842 /doc/Unit-tests.md | |
parent | d5d22a6d07917865c44148ad76f43c65a929a890 (diff) | |
download | Shaarli-53ed6d7d1e678d7486337ce67a2f17b30bac21ac.tar.gz Shaarli-53ed6d7d1e678d7486337ce67a2f17b30bac21ac.tar.zst Shaarli-53ed6d7d1e678d7486337ce67a2f17b30bac21ac.zip |
Generate HTML documentation using MkDocs (WIP)
MkDocs is a static site generator geared towards building project documentation.
Documentation source files are written in Markdown, and configured with a single YAML file.
* http://www.mkdocs.org/
* http://www.mkdocs.org/user-guide/configuration/
Ref. #312
* remove pandoc-generated HTML documentation
* move markdown doc to doc/md/,
* mkdocs.yml:
* generate HTML doc in doc/html
* add pages TOC/ordering
* use index.md as index page
* Makefile: remove execute permissions from generated files
* Makefile: rewrite htmlpages GFM to markdown conversion using sed:
awk expression aslo matched '][' which causes invalid output on complex links with images or code blocks
* Add mkdocs.yml to .gitattributes, exclude this file from release archives
* Makefile: rename: htmldoc -> doc_html target
* run make doc: pull latest markdown documentation from wiki
* run make htmlpages: update html documentation
Diffstat (limited to 'doc/Unit-tests.md')
-rw-r--r-- | doc/Unit-tests.md | 147 |
1 files changed, 0 insertions, 147 deletions
diff --git a/doc/Unit-tests.md b/doc/Unit-tests.md deleted file mode 100644 index 0942ad38..00000000 --- a/doc/Unit-tests.md +++ /dev/null | |||
@@ -1,147 +0,0 @@ | |||
1 | #Unit tests | ||
2 | |||
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) | ||
5 | |||
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) | ||
9 | |||
10 | #### Sample usage | ||
11 | ```bash | ||
12 | # system-wide version | ||
13 | $ composer install | ||
14 | $ composer update | ||
15 | |||
16 | # local version | ||
17 | $ php composer.phar self-update | ||
18 | $ php composer.phar install | ||
19 | $ php composer.phar update | ||
20 | ``` | ||
21 | |||
22 | #### Install Shaarli dev dependencies | ||
23 | ```bash | ||
24 | $ cd /path/to/shaarli | ||
25 | $ composer update | ||
26 | ``` | ||
27 | |||
28 | #### Install and enable Xdebug to generate PHPUnit coverage reports | ||
29 | For Debian-based distros: | ||
30 | ```bash | ||
31 | $ aptitude install php5-xdebug | ||
32 | ``` | ||
33 | For ArchLinux: | ||
34 | ```bash | ||
35 | $ pacman -S xdebug | ||
36 | ``` | ||
37 | |||
38 | Then add the following line to `/etc/php/php.ini`: | ||
39 | ```ini | ||
40 | zend_extension=xdebug.so | ||
41 | ``` | ||
42 | |||
43 | #### Run unit tests | ||
44 | Successful test suite: | ||
45 | ```bash | ||
46 | $ make test | ||
47 | |||
48 | ------- | ||
49 | PHPUNIT | ||
50 | ------- | ||
51 | PHPUnit 4.6.9 by Sebastian Bergmann and contributors. | ||
52 | |||
53 | Configuration read from /home/virtualtam/public_html/shaarli/phpunit.xml | ||
54 | |||
55 | .................................... | ||
56 | |||
57 | Time: 759 ms, Memory: 8.25Mb | ||
58 | |||
59 | OK (36 tests, 65 assertions) | ||
60 | ``` | ||
61 | |||
62 | Test suite with failures and errors: | ||
63 | ```bash | ||
64 | $ make test | ||
65 | ------- | ||
66 | PHPUNIT | ||
67 | ------- | ||
68 | PHPUnit 4.6.9 by Sebastian Bergmann and contributors. | ||
69 | |||
70 | Configuration read from /home/virtualtam/public_html/shaarli/phpunit.xml | ||
71 | |||
72 | E..FF............................... | ||
73 | |||
74 | Time: 802 ms, Memory: 8.25Mb | ||
75 | |||
76 | There was 1 error: | ||
77 | |||
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 | ||
81 | |||
82 | /home/virtualtam/public_html/shaarli/application/LinkDB.php:58 | ||
83 | /home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:79 | ||
84 | |||
85 | -- | ||
86 | |||
87 | There were 2 failures: | ||
88 | |||
89 | 1) LinkDBTest::testCheckDBNew | ||
90 | Failed asserting that two strings are equal. | ||
91 | --- Expected | ||
92 | +++ Actual | ||
93 | @@ @@ | ||
94 | -'e3edea8ea7bb50be4bcb404df53fbb4546a7156e' | ||
95 | +'85eab0c610d4f68025f6ed6e6b6b5fabd4b55834' | ||
96 | |||
97 | /home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:121 | ||
98 | |||
99 | 2) LinkDBTest::testCheckDBLoad | ||
100 | Failed asserting that two strings are equal. | ||
101 | --- Expected | ||
102 | +++ Actual | ||
103 | @@ @@ | ||
104 | -'e3edea8ea7bb50be4bcb404df53fbb4546a7156e' | ||
105 | +'85eab0c610d4f68025f6ed6e6b6b5fabd4b55834' | ||
106 | |||
107 | /home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:133 | ||
108 | |||
109 | FAILURES! | ||
110 | Tests: 36, Assertions: 63, Errors: 1, Failures: 2. | ||
111 | ``` | ||
112 | |||
113 | #### Test results and coverage | ||
114 | By default, PHPUnit will run all suitable tests found under the `tests` directory. | ||
115 | |||
116 | Each test has 3 possible outcomes: | ||
117 | * `.` - success | ||
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 | ||
124 | |||
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 &` | ||
129 | |||
130 | ### Executing specific tests | ||
131 | Add a [`@group`](https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.group) annotation in a test class or method comment:[](.html) | ||
132 | |||
133 | ```php | ||
134 | /** | ||
135 | * Netscape bookmark import | ||
136 | * @group WIP | ||
137 | */ | ||
138 | class BookmarkImportTest extends PHPUnit_Framework_TestCase | ||
139 | { | ||
140 | [...][](.html) | ||
141 | } | ||
142 | ``` | ||
143 | |||
144 | To run all tests annotated with `@group WIP`: | ||
145 | ```bash | ||
146 | $ vendor/bin/phpunit --group WIP tests/ | ||
147 | ``` | ||