diff options
author | nodiscc <nodiscc@gmail.com> | 2020-05-16 12:54:51 +0200 |
---|---|---|
committer | nodiscc <nodiscc@gmail.com> | 2020-09-12 14:31:45 +0200 |
commit | 91a21c272960889afd4eaa431a3d29b7785b6efc (patch) | |
tree | 26e3ba62319964c5fd48d93fdfe47813d5dc9bf5 /doc/md/Unit-tests.md | |
parent | 6128ab6a55430a2b705be31ff417c0c552a0db1f (diff) | |
download | Shaarli-91a21c272960889afd4eaa431a3d29b7785b6efc.tar.gz Shaarli-91a21c272960889afd4eaa431a3d29b7785b6efc.tar.zst Shaarli-91a21c272960889afd4eaa431a3d29b7785b6efc.zip |
**General rewording, proof-reading, deduplication, shortening, reordering, simplification, cleanup/formatting/standardization**
- standardize page names, rework documentation structure, update TOC
- use same example paths everywhere
- level 1 titles on all pages
- fix broken links
- .md suffix on all page links (works both from readthedocs and github repository views)
**Server:**
A full and concise installation guide with examples is a frequent request. The documentation should provide such a guide for basic installation needs, while explaining alternative/advanced configuration at the end. Links to reference guides and documentation should be used more frequently to avoid recommending an outdated or excessively complex configuration.
- server: move most server-related info to server-configuration.md, cleanup/shorten
- server: update list of php dependencies/libraries, link to composer.json
- server: installation: support 3 install methods (from release zip, from sources, using docker)
- server: installation: use rsync instead of mv as mv results will change depending of taget directory already existing or not
- server: add example/basic usage of certbot
- server, upgrade, installation: update file permissions setup, use sudo for upgrade operations in webserver document root
- server: apache: add comments to configuration, fix and factorize file permissions setup, set cache-control header, deny access to dotfiles, add missing apache config steps, add http->https redirect example
- server: nginx: refactor nginx configuration, add comments, DO log access to denied/protected files
- server: add links to MDN for x-forwarded-* http headers explanation, cleanup/clarify robots.txt and crawlers section
- server: bump file upload size limit to 100MB we have reports of bookmark exports weighing +40MB - i have a 13MB one here
- server: simplify phpinfo documentation
- server: move backup and restore information to dedicated page
- docker: move all docker docs to Docker.md, simplify/ docker setup, add docker-compose.yml example, replace docker-101 with docker cheatsheet
- troubleshooting: move all troubleshooting documentation to troubleshooting.md
**Usage:**
- index: add getting started section on index page
- features/usage: move all usage-related documentation to usage.md, add links from the main feature list to corresponding usage docs, clarify/reword features list
- shaarli configuration: add note about configuring from web interface
**Removed:**
- remove obsolete/orphan images
- remove obsolete shaarchiver example
- remove outdated "decode datastore content" snippet
**Development:**
- development: move development-related docs (static analysis, CI, unit tests, 3rd party libs, link structure/directory, guidelines, security....) to dev/ directory
- development: Merge several pages to development.md
- **Breaking change?:** remove mentions of 'stable' branch, switch to new branch/release model (master=latest commit, release=latest tag)
- **Breaking change?:** refer to base sharing unit as "Shaare" everywhere (TODO: reflect changes in the code?) doc: update featues list/link to usage.md for details
- development: directory structure: add note about required file permissions
- .travis-ci.yml: add comments
- .htaccess: add comment
Diffstat (limited to 'doc/md/Unit-tests.md')
-rw-r--r-- | doc/md/Unit-tests.md | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/doc/md/Unit-tests.md b/doc/md/Unit-tests.md deleted file mode 100644 index a9544656..00000000 --- a/doc/md/Unit-tests.md +++ /dev/null | |||
@@ -1,119 +0,0 @@ | |||
1 | The testing framework used is [PHPUnit](https://phpunit.de/); it can be installed with [Composer](https://getcomposer.org/), which is a dependency management tool. | ||
2 | |||
3 | ## Setup a testing environment | ||
4 | |||
5 | ### Install composer | ||
6 | |||
7 | You can either use: | ||
8 | |||
9 | - a system-wide version, e.g. installed through your distro's package manager (eg. `sudo apt install composer`) | ||
10 | - a local version, downloadable [here](https://getcomposer.org/download/). To update a local composer installation, run `php composer.phar self-update` | ||
11 | |||
12 | |||
13 | ### Install Shaarli development dependencies | ||
14 | |||
15 | ```bash | ||
16 | $ cd /path/to/shaarli | ||
17 | $ composer install | ||
18 | ``` | ||
19 | |||
20 | ### Install Xdebug | ||
21 | |||
22 | Xdebug must be installed and enable for PHPUnit to generate coverage reports. See http://xdebug.org/docs/install. | ||
23 | |||
24 | ```bash | ||
25 | # for Debian-based distributions | ||
26 | $ aptitude install php-xdebug | ||
27 | |||
28 | # for ArchLinux: | ||
29 | $ pacman -S xdebug | ||
30 | ``` | ||
31 | |||
32 | Then add the following line to `/etc/php/<PHP_VERSION>/cli/php.ini`: | ||
33 | |||
34 | ```ini | ||
35 | zend_extension=xdebug.so | ||
36 | ``` | ||
37 | |||
38 | ## Run unit tests | ||
39 | |||
40 | Run `make test` and ensure tests return `OK`. If tests return failures, refer to PHPUnit messages and fix your code/tests accordingly. | ||
41 | |||
42 | By default, PHPUnit will run all suitable tests found under the `tests` directory. Each test has 3 possible outcomes: | ||
43 | |||
44 | - `.` - success | ||
45 | - `F` - failure: the test was run but its results are invalid | ||
46 | - the code does not behave as expected | ||
47 | - dependencies to external elements: globals, session, cache... | ||
48 | - `E` - error: something went wrong and the tested code has crashed | ||
49 | - typos in the code, or in the test code | ||
50 | - dependencies to missing external elements | ||
51 | |||
52 | If Xdebug has been installed and activated, two coverage reports will be generated: | ||
53 | |||
54 | - a summary in the console | ||
55 | - a detailed HTML report with metrics for tested code | ||
56 | - to open it in a web browser: `firefox coverage/index.html &` | ||
57 | |||
58 | ### Executing specific tests | ||
59 | |||
60 | Add a [`@group`](https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.group) annotation in a test class or method comment: | ||
61 | |||
62 | ```php | ||
63 | /** | ||
64 | * Netscape bookmark import | ||
65 | * @group WIP | ||
66 | */ | ||
67 | class BookmarkImportTest extends PHPUnit_Framework_TestCase | ||
68 | { | ||
69 | [...] | ||
70 | } | ||
71 | ``` | ||
72 | |||
73 | To run all tests annotated with `@group WIP`: | ||
74 | ```bash | ||
75 | $ vendor/bin/phpunit --group WIP tests/ | ||
76 | ``` | ||
77 | |||
78 | ### Running tests inside Docker containers | ||
79 | |||
80 | Test Dockerfiles are located under `tests/docker/<distribution>/Dockerfile`, | ||
81 | and can be used to build Docker images to run Shaarli test suites under common | ||
82 | Linux environments. | ||
83 | |||
84 | Dockerfiles are provided for the following environments: | ||
85 | |||
86 | - `alpine36` - [Alpine 3.6](https://www.alpinelinux.org/downloads/) | ||
87 | - `debian8` - [Debian 8 Jessie](https://www.debian.org/DebianJessie) (oldstable) | ||
88 | - `debian9` - [Debian 9 Stretch](https://wiki.debian.org/DebianStretch) (stable) | ||
89 | - `ubuntu16` - [Ubuntu 16.04 Xenial Xerus](http://releases.ubuntu.com/16.04/) (LTS) | ||
90 | |||
91 | What's behind the curtains: | ||
92 | |||
93 | - each image provides: | ||
94 | - a base Linux OS | ||
95 | - Shaarli PHP dependencies (OS packages) | ||
96 | - test PHP dependencies (OS packages) | ||
97 | - Composer | ||
98 | - the local workspace is mapped to the container's `/shaarli/` directory, | ||
99 | - the files are rsync'd so tests are run using a standard Linux user account | ||
100 | (running tests as `root` would bypass permission checks and may hide issues) | ||
101 | - the tests are run inside the container. | ||
102 | |||
103 | To run tests inside a Docker container: | ||
104 | |||
105 | ```bash | ||
106 | # build the Debian 9 Docker image for unit tests | ||
107 | $ cd /path/to/shaarli | ||
108 | $ cd tests/docker/debian9 | ||
109 | $ docker build -t shaarli-test:debian9 . | ||
110 | |||
111 | # install/update 3rd-party test dependencies | ||
112 | $ composer install --prefer-dist | ||
113 | |||
114 | # run tests using the freshly built image | ||
115 | $ docker run -v $PWD:/shaarli shaarli-test:debian9 docker_test | ||
116 | |||
117 | # run the full test campaign | ||
118 | $ docker run -v $PWD:/shaarli shaarli-test:debian9 docker_all_tests | ||
119 | ``` | ||