aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/md/Plugin-System.md9
-rw-r--r--doc/md/Server-configuration.md2
-rw-r--r--doc/md/Server-security.md8
-rw-r--r--doc/md/Unit-tests-Docker.md56
-rw-r--r--doc/md/Unit-tests.md158
5 files changed, 72 insertions, 161 deletions
diff --git a/doc/md/Plugin-System.md b/doc/md/Plugin-System.md
index 9b0d3a7d..d5b16e2d 100644
--- a/doc/md/Plugin-System.md
+++ b/doc/md/Plugin-System.md
@@ -18,7 +18,7 @@ The plugin system let you:
18 18
19First, chose a plugin name, such as `demo_plugin`. 19First, chose a plugin name, such as `demo_plugin`.
20 20
21Under `plugin` folder, create a folder named with your plugin name. Then create a <plugin_name>.php file in that folder. 21Under `plugin` folder, create a folder named with your plugin name. Then create a <plugin_name>.meta file and a <plugin_name>.php file in that folder.
22 22
23You should have the following tree view: 23You should have the following tree view:
24 24
@@ -26,17 +26,22 @@ You should have the following tree view:
26| index.php 26| index.php
27| plugins/ 27| plugins/
28|---| demo_plugin/ 28|---| demo_plugin/
29| |---| demo_plugin.meta
29| |---| demo_plugin.php 30| |---| demo_plugin.php
30``` 31```
31 32
32### Plugin initialization 33### Plugin initialization
33 34
34At the beginning of Shaarli execution, all enabled plugins are loaded. At this point, the plugin system looks for an `init()` function to execute and run it if it exists. This function must be named this way, and takes the `ConfigManager` as parameter. 35At the beginning of Shaarli execution, all enabled plugins are loaded. At this point, the plugin system looks for an `init()` function in the <plugin_name>.php to execute and run it if it exists. This function must be named this way, and takes the `ConfigManager` as parameter.
35 36
36 <plugin_name>_init($conf) 37 <plugin_name>_init($conf)
37 38
38This function can be used to create initial data, load default settings, etc. But also to set *plugin errors*. If the initialization function returns an array of strings, they will be understand as errors, and displayed in the header to logged in users. 39This function can be used to create initial data, load default settings, etc. But also to set *plugin errors*. If the initialization function returns an array of strings, they will be understand as errors, and displayed in the header to logged in users.
39 40
41The plugin system also looks for a `description` variable in the <plugin_name>.meta file, to be displayed in the plugin administration page.
42
43 description="The plugin does this and that."
44
40### Understanding hooks 45### Understanding hooks
41 46
42A plugin is a set of functions. Each function will be triggered by the plugin system at certain point in Shaarli execution. 47A plugin is a set of functions. Each function will be triggered by the plugin system at certain point in Shaarli execution.
diff --git a/doc/md/Server-configuration.md b/doc/md/Server-configuration.md
index bd293c37..f9ea2ed2 100644
--- a/doc/md/Server-configuration.md
+++ b/doc/md/Server-configuration.md
@@ -187,7 +187,7 @@ http {
187``` 187```
188 188
189```ini 189```ini
190# /etc/php5/fpm/php.ini 190# /etc/php/<PHP_VERSION>/fpm/php.ini
191 191
192[...] 192[...]
193post_max_size = 10M 193post_max_size = 10M
diff --git a/doc/md/Server-security.md b/doc/md/Server-security.md
index 700084e2..ea1b637d 100644
--- a/doc/md/Server-security.md
+++ b/doc/md/Server-security.md
@@ -1,10 +1,10 @@
1## php.ini 1## php.ini
2PHP settings are defined in: 2PHP settings are defined in:
3 3
4- a main configuration file, usually found under `/etc/php5/php.ini`; some distributions provide different configuration environments, e.g. 4- a main configuration file, usually found under `/etc/php/$php_version/php.ini`; some distributions provide different configuration environments, e.g.
5 - `/etc/php5/php.ini` - used when running console scripts 5 - `/etc/php/$php_version/cli/php.ini` - used when running console scripts
6 - `/etc/php5/apache2/php.ini` - used when a client requests PHP resources from Apache 6 - `/etc/php/$php_version/apache2/php.ini` - used when a client requests PHP resources from Apache
7 - `/etc/php5/php-fpm.conf` - used when PHP requests are proxied to PHP-FPM 7 - `/etc/php/$php_version/php-fpm.conf` - used when PHP requests are proxied to PHP-FPM
8- additional configuration files/entries, depending on the installed/enabled extensions: 8- additional configuration files/entries, depending on the installed/enabled extensions:
9 - `/etc/php/conf.d/xdebug.ini` 9 - `/etc/php/conf.d/xdebug.ini`
10 10
diff --git a/doc/md/Unit-tests-Docker.md b/doc/md/Unit-tests-Docker.md
deleted file mode 100644
index 59bd5b45..00000000
--- a/doc/md/Unit-tests-Docker.md
+++ /dev/null
@@ -1,56 +0,0 @@
1## Running tests inside Docker containers
2
3Read first:
4
5- [Docker 101](docker/docker-101.md)
6- [Docker resources](docker/resources.md)
7- [Unit tests](Unit-tests.md)
8
9### Docker test images
10
11Test Dockerfiles are located under `tests/docker/<distribution>/Dockerfile`,
12and can be used to build Docker images to run Shaarli test suites under common
13Linux environments.
14
15Dockerfiles are provided for the following environments:
16
17- `alpine36` - [Alpine 3.6](https://www.alpinelinux.org/downloads/)
18- `debian8` - [Debian 8 Jessie](https://www.debian.org/DebianJessie) (oldstable)
19- `debian9` - [Debian 9 Stretch](https://wiki.debian.org/DebianStretch) (stable)
20- `ubuntu16` - [Ubuntu 16.04 Xenial Xerus](http://releases.ubuntu.com/16.04/) (LTS)
21
22What's behind the curtains:
23
24- each image provides:
25 - a base Linux OS
26 - Shaarli PHP dependencies (OS packages)
27 - test PHP dependencies (OS packages)
28 - Composer
29- the local workspace is mapped to the container's `/shaarli/` directory,
30- the files are rsync'd so tests are run using a standard Linux user account
31 (running tests as `root` would bypass permission checks and may hide issues)
32- the tests are run inside the container.
33
34### Building test images
35
36```bash
37# build the Debian 9 Docker image
38$ cd /path/to/shaarli
39$ cd tests/docker/debian9
40$ docker build -t shaarli-test:debian9 .
41```
42
43### Running tests
44
45```bash
46$ cd /path/to/shaarli
47
48# install/update 3rd-party test dependencies
49$ composer install --prefer-dist
50
51# run tests using the freshly built image
52$ docker run -v $PWD:/shaarli shaarli-test:debian9 docker_test
53
54# run the full test campaign
55$ docker run -v $PWD:/shaarli shaarli-test:debian9 docker_all_tests
56```
diff --git a/doc/md/Unit-tests.md b/doc/md/Unit-tests.md
index f6030d5c..a9544656 100644
--- a/doc/md/Unit-tests.md
+++ b/doc/md/Unit-tests.md
@@ -1,126 +1,45 @@
1### Setup your environment for tests 1The testing framework used is [PHPUnit](https://phpunit.de/); it can be installed with [Composer](https://getcomposer.org/), which is a dependency management tool.
2 2
3The framework used is [PHPUnit](https://phpunit.de/); it can be installed with [Composer](https://getcomposer.org/), which is a dependency management tool. 3## Setup a testing environment
4 4
5### Install composer 5### Install composer
6 6
7You can either use: 7You can either use:
8 8
9- a system-wide version, e.g. installed through your distro's package manager 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/). 10- a local version, downloadable [here](https://getcomposer.org/download/). To update a local composer installation, run `php composer.phar self-update`
11 11
12```bash
13# system-wide version
14$ composer install
15$ composer update
16
17# local version
18$ php composer.phar self-update
19$ php composer.phar install
20$ php composer.phar update
21```
22 12
23#### Install Shaarli dev dependencies 13### Install Shaarli development dependencies
24 14
25```bash 15```bash
26$ cd /path/to/shaarli 16$ cd /path/to/shaarli
27$ composer update 17$ composer install
28``` 18```
29 19
30#### Install and enable Xdebug to generate PHPUnit coverage reports 20### Install Xdebug
31 21
32See http://xdebug.org/docs/install 22Xdebug must be installed and enable for PHPUnit to generate coverage reports. See http://xdebug.org/docs/install.
33 23
34For Debian-based distros:
35```bash
36$ aptitude install php5-xdebug
37```
38For ArchLinux:
39```bash 24```bash
25# for Debian-based distributions
26$ aptitude install php-xdebug
27
28# for ArchLinux:
40$ pacman -S xdebug 29$ pacman -S xdebug
41``` 30```
42 31
43Then add the following line to `/etc/php/php.ini`: 32Then add the following line to `/etc/php/<PHP_VERSION>/cli/php.ini`:
33
44```ini 34```ini
45zend_extension=xdebug.so 35zend_extension=xdebug.so
46``` 36```
47 37
48#### Run unit tests 38## Run unit tests
49
50Successful test suite:
51```bash
52$ make test
53
54-------
55PHPUNIT
56-------
57PHPUnit 4.6.9 by Sebastian Bergmann and contributors.
58
59Configuration read from /home/virtualtam/public_html/shaarli/phpunit.xml
60
61....................................
62
63Time: 759 ms, Memory: 8.25Mb
64
65OK (36 tests, 65 assertions)
66```
67
68Test suite with failures and errors:
69```bash
70$ make test
71-------
72PHPUNIT
73-------
74PHPUnit 4.6.9 by Sebastian Bergmann and contributors.
75
76Configuration read from /home/virtualtam/public_html/shaarli/phpunit.xml
77
78E..FF...............................
79
80Time: 802 ms, Memory: 8.25Mb
81
82There was 1 error:
83
841) LinkDBTest::testConstructLoggedIn
85Missing argument 2 for LinkDB::__construct(), called in /home/virtualtam/public_html/shaarli/tests/Link\
86DBTest.php on line 79 and defined
87
88/home/virtualtam/public_html/shaarli/application/LinkDB.php:58
89/home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:79
90
91--
92
93There were 2 failures:
94
951) LinkDBTest::testCheckDBNew
96Failed asserting that two strings are equal.
97--- Expected
98+++ Actual
99@@ @@
100-'e3edea8ea7bb50be4bcb404df53fbb4546a7156e'
101+'85eab0c610d4f68025f6ed6e6b6b5fabd4b55834'
102
103/home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:121
104
1052) LinkDBTest::testCheckDBLoad
106Failed asserting that two strings are equal.
107--- Expected
108+++ Actual
109@@ @@
110-'e3edea8ea7bb50be4bcb404df53fbb4546a7156e'
111+'85eab0c610d4f68025f6ed6e6b6b5fabd4b55834'
112
113/home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:133
114
115FAILURES!
116Tests: 36, Assertions: 63, Errors: 1, Failures: 2.
117```
118
119#### Test results and coverage
120 39
121By default, PHPUnit will run all suitable tests found under the `tests` directory. 40Run `make test` and ensure tests return `OK`. If tests return failures, refer to PHPUnit messages and fix your code/tests accordingly.
122 41
123Each test has 3 possible outcomes: 42By default, PHPUnit will run all suitable tests found under the `tests` directory. Each test has 3 possible outcomes:
124 43
125- `.` - success 44- `.` - success
126- `F` - failure: the test was run but its results are invalid 45- `F` - failure: the test was run but its results are invalid
@@ -155,3 +74,46 @@ To run all tests annotated with `@group WIP`:
155```bash 74```bash
156$ vendor/bin/phpunit --group WIP tests/ 75$ vendor/bin/phpunit --group WIP tests/
157``` 76```
77
78### Running tests inside Docker containers
79
80Test Dockerfiles are located under `tests/docker/<distribution>/Dockerfile`,
81and can be used to build Docker images to run Shaarli test suites under common
82Linux environments.
83
84Dockerfiles 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
91What'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
103To 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```