From 6fa3c87d32dd16655ffb37865e1585b2b35154cd Mon Sep 17 00:00:00 2001 From: nodiscc Date: Sun, 19 Jan 2020 12:40:28 +0100 Subject: doc: simplify composer installation procedure --- doc/md/Unit-tests.md | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'doc') diff --git a/doc/md/Unit-tests.md b/doc/md/Unit-tests.md index f6030d5c..74920ac1 100644 --- a/doc/md/Unit-tests.md +++ b/doc/md/Unit-tests.md @@ -6,24 +6,15 @@ The framework used is [PHPUnit](https://phpunit.de/); it can be installed with [ You can either use: -- a system-wide version, e.g. installed through your distro's package manager -- a local version, downloadable [here](https://getcomposer.org/download/). +- a system-wide version, e.g. installed through your distro's package manager (eg. `sudo apt install composer`) +- a local version, downloadable [here](https://getcomposer.org/download/). To update a local composer installation, run `php composer.phar self-update` -```bash -# system-wide version -$ composer install -$ composer update - -# local version -$ php composer.phar self-update -$ php composer.phar install -$ php composer.phar update -``` #### Install Shaarli dev dependencies ```bash $ cd /path/to/shaarli +$ composer install $ composer update ``` -- cgit v1.2.3 From 7a7a5237822207171e535fc00de253fbfd25c5a2 Mon Sep 17 00:00:00 2001 From: nodiscc Date: Sun, 19 Jan 2020 13:09:23 +0100 Subject: doc: simplify unit tests documentation --- doc/md/Unit-tests.md | 75 +++------------------------------------------------- 1 file changed, 4 insertions(+), 71 deletions(-) (limited to 'doc') diff --git a/doc/md/Unit-tests.md b/doc/md/Unit-tests.md index 74920ac1..da993109 100644 --- a/doc/md/Unit-tests.md +++ b/doc/md/Unit-tests.md @@ -22,12 +22,11 @@ $ composer update See http://xdebug.org/docs/install -For Debian-based distros: ```bash +# for Debian-based distributions $ aptitude install php5-xdebug -``` -For ArchLinux: -```bash + +# for ArchLinux: $ pacman -S xdebug ``` @@ -38,74 +37,8 @@ zend_extension=xdebug.so #### Run unit tests -Successful test suite: -```bash -$ make test - -------- -PHPUNIT -------- -PHPUnit 4.6.9 by Sebastian Bergmann and contributors. - -Configuration read from /home/virtualtam/public_html/shaarli/phpunit.xml - -.................................... - -Time: 759 ms, Memory: 8.25Mb - -OK (36 tests, 65 assertions) -``` - -Test suite with failures and errors: -```bash -$ make test -------- -PHPUNIT -------- -PHPUnit 4.6.9 by Sebastian Bergmann and contributors. - -Configuration read from /home/virtualtam/public_html/shaarli/phpunit.xml +Run `make test` and ensure tests return `OK`. If tests return failures, refer to PHPUnit messages and fix your code/tests accordingly. -E..FF............................... - -Time: 802 ms, Memory: 8.25Mb - -There was 1 error: - -1) LinkDBTest::testConstructLoggedIn -Missing argument 2 for LinkDB::__construct(), called in /home/virtualtam/public_html/shaarli/tests/Link\ -DBTest.php on line 79 and defined - -/home/virtualtam/public_html/shaarli/application/LinkDB.php:58 -/home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:79 - --- - -There were 2 failures: - -1) LinkDBTest::testCheckDBNew -Failed asserting that two strings are equal. ---- Expected -+++ Actual -@@ @@ --'e3edea8ea7bb50be4bcb404df53fbb4546a7156e' -+'85eab0c610d4f68025f6ed6e6b6b5fabd4b55834' - -/home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:121 - -2) LinkDBTest::testCheckDBLoad -Failed asserting that two strings are equal. ---- Expected -+++ Actual -@@ @@ --'e3edea8ea7bb50be4bcb404df53fbb4546a7156e' -+'85eab0c610d4f68025f6ed6e6b6b5fabd4b55834' - -/home/virtualtam/public_html/shaarli/tests/LinkDBTest.php:133 - -FAILURES! -Tests: 36, Assertions: 63, Errors: 1, Failures: 2. -``` #### Test results and coverage -- cgit v1.2.3 From a8a38401f006fdaeb97896ed1c6429d0ab825eb8 Mon Sep 17 00:00:00 2001 From: nodiscc Date: Sun, 19 Jan 2020 13:11:11 +0100 Subject: doc: reword simplify xdebug installation/unit tests --- doc/md/Unit-tests.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'doc') diff --git a/doc/md/Unit-tests.md b/doc/md/Unit-tests.md index da993109..651b546d 100644 --- a/doc/md/Unit-tests.md +++ b/doc/md/Unit-tests.md @@ -18,9 +18,9 @@ $ composer install $ composer update ``` -#### Install and enable Xdebug to generate PHPUnit coverage reports +#### Install Xdebug -See http://xdebug.org/docs/install +Xdebug must be installed and enable for PHPUnit to generate coverage reports. See http://xdebug.org/docs/install. ```bash # for Debian-based distributions @@ -31,6 +31,7 @@ $ pacman -S xdebug ``` Then add the following line to `/etc/php/php.ini`: + ```ini zend_extension=xdebug.so ``` @@ -39,12 +40,7 @@ zend_extension=xdebug.so Run `make test` and ensure tests return `OK`. If tests return failures, refer to PHPUnit messages and fix your code/tests accordingly. - -#### Test results and coverage - -By default, PHPUnit will run all suitable tests found under the `tests` directory. - -Each test has 3 possible outcomes: +By default, PHPUnit will run all suitable tests found under the `tests` directory. Each test has 3 possible outcomes: - `.` - success - `F` - failure: the test was run but its results are invalid -- cgit v1.2.3 From 54ab5636e3a4f496ed96178470f50dec6c6196b2 Mon Sep 17 00:00:00 2001 From: nodiscc Date: Sun, 19 Jan 2020 13:18:29 +0100 Subject: doc: merge unit tests/docker unit tests pages, simplfy, reword --- doc/md/Unit-tests-Docker.md | 56 --------------------------------------------- doc/md/Unit-tests.md | 53 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 61 deletions(-) delete mode 100644 doc/md/Unit-tests-Docker.md (limited to 'doc') 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 @@ -## Running tests inside Docker containers - -Read first: - -- [Docker 101](docker/docker-101.md) -- [Docker resources](docker/resources.md) -- [Unit tests](Unit-tests.md) - -### Docker test images - -Test Dockerfiles are located under `tests/docker//Dockerfile`, -and can be used to build Docker images to run Shaarli test suites under common -Linux environments. - -Dockerfiles are provided for the following environments: - -- `alpine36` - [Alpine 3.6](https://www.alpinelinux.org/downloads/) -- `debian8` - [Debian 8 Jessie](https://www.debian.org/DebianJessie) (oldstable) -- `debian9` - [Debian 9 Stretch](https://wiki.debian.org/DebianStretch) (stable) -- `ubuntu16` - [Ubuntu 16.04 Xenial Xerus](http://releases.ubuntu.com/16.04/) (LTS) - -What's behind the curtains: - -- each image provides: - - a base Linux OS - - Shaarli PHP dependencies (OS packages) - - test PHP dependencies (OS packages) - - Composer -- the local workspace is mapped to the container's `/shaarli/` directory, -- the files are rsync'd so tests are run using a standard Linux user account - (running tests as `root` would bypass permission checks and may hide issues) -- the tests are run inside the container. - -### Building test images - -```bash -# build the Debian 9 Docker image -$ cd /path/to/shaarli -$ cd tests/docker/debian9 -$ docker build -t shaarli-test:debian9 . -``` - -### Running tests - -```bash -$ cd /path/to/shaarli - -# install/update 3rd-party test dependencies -$ composer install --prefer-dist - -# run tests using the freshly built image -$ docker run -v $PWD:/shaarli shaarli-test:debian9 docker_test - -# run the full test campaign -$ docker run -v $PWD:/shaarli shaarli-test:debian9 docker_all_tests -``` diff --git a/doc/md/Unit-tests.md b/doc/md/Unit-tests.md index 651b546d..c45f957d 100644 --- a/doc/md/Unit-tests.md +++ b/doc/md/Unit-tests.md @@ -1,6 +1,6 @@ -### Setup your environment for tests +The testing framework used is [PHPUnit](https://phpunit.de/); it can be installed with [Composer](https://getcomposer.org/), which is a dependency management tool. -The framework used is [PHPUnit](https://phpunit.de/); it can be installed with [Composer](https://getcomposer.org/), which is a dependency management tool. +## Setup a testing environment ### Install composer @@ -10,7 +10,7 @@ You can either use: - a local version, downloadable [here](https://getcomposer.org/download/). To update a local composer installation, run `php composer.phar self-update` -#### Install Shaarli dev dependencies +### Install Shaarli development dependencies ```bash $ cd /path/to/shaarli @@ -18,7 +18,7 @@ $ composer install $ composer update ``` -#### Install Xdebug +### Install Xdebug Xdebug must be installed and enable for PHPUnit to generate coverage reports. See http://xdebug.org/docs/install. @@ -36,7 +36,7 @@ Then add the following line to `/etc/php/php.ini`: zend_extension=xdebug.so ``` -#### Run unit tests +## Run unit tests Run `make test` and ensure tests return `OK`. If tests return failures, refer to PHPUnit messages and fix your code/tests accordingly. @@ -75,3 +75,46 @@ To run all tests annotated with `@group WIP`: ```bash $ vendor/bin/phpunit --group WIP tests/ ``` + +### Running tests inside Docker containers + +Test Dockerfiles are located under `tests/docker//Dockerfile`, +and can be used to build Docker images to run Shaarli test suites under common +Linux environments. + +Dockerfiles are provided for the following environments: + +- `alpine36` - [Alpine 3.6](https://www.alpinelinux.org/downloads/) +- `debian8` - [Debian 8 Jessie](https://www.debian.org/DebianJessie) (oldstable) +- `debian9` - [Debian 9 Stretch](https://wiki.debian.org/DebianStretch) (stable) +- `ubuntu16` - [Ubuntu 16.04 Xenial Xerus](http://releases.ubuntu.com/16.04/) (LTS) + +What's behind the curtains: + +- each image provides: + - a base Linux OS + - Shaarli PHP dependencies (OS packages) + - test PHP dependencies (OS packages) + - Composer +- the local workspace is mapped to the container's `/shaarli/` directory, +- the files are rsync'd so tests are run using a standard Linux user account + (running tests as `root` would bypass permission checks and may hide issues) +- the tests are run inside the container. + +To run tests inside a Docker container: + +```bash +# build the Debian 9 Docker image for unit tests +$ cd /path/to/shaarli +$ cd tests/docker/debian9 +$ docker build -t shaarli-test:debian9 . + +# install/update 3rd-party test dependencies +$ composer install --prefer-dist + +# run tests using the freshly built image +$ docker run -v $PWD:/shaarli shaarli-test:debian9 docker_test + +# run the full test campaign +$ docker run -v $PWD:/shaarli shaarli-test:debian9 docker_all_tests +``` -- cgit v1.2.3 From 3b04d19a6265b43d8593d53b682072643f12853a Mon Sep 17 00:00:00 2001 From: nodiscc Date: Sun, 19 Jan 2020 13:49:48 +0100 Subject: doc: fix reference to old version of php-xdebug package --- doc/md/Unit-tests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/md/Unit-tests.md b/doc/md/Unit-tests.md index c45f957d..7eebf18e 100644 --- a/doc/md/Unit-tests.md +++ b/doc/md/Unit-tests.md @@ -24,7 +24,7 @@ Xdebug must be installed and enable for PHPUnit to generate coverage reports. Se ```bash # for Debian-based distributions -$ aptitude install php5-xdebug +$ aptitude install php-xdebug # for ArchLinux: $ pacman -S xdebug -- cgit v1.2.3 From 04a816f648edeaeb7d1545064b87b4b2135a43e8 Mon Sep 17 00:00:00 2001 From: nodiscc Date: Sun, 19 Jan 2020 13:52:03 +0100 Subject: doc: fix references to php5, use new directory structure --- doc/md/Server-configuration.md | 2 +- doc/md/Server-security.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'doc') diff --git a/doc/md/Server-configuration.md b/doc/md/Server-configuration.md index bd293c37..bc6ac980 100644 --- a/doc/md/Server-configuration.md +++ b/doc/md/Server-configuration.md @@ -187,7 +187,7 @@ http { ``` ```ini -# /etc/php5/fpm/php.ini +# /etc/php/$php_version/fpm/php.ini [...] post_max_size = 10M diff --git a/doc/md/Server-security.md b/doc/md/Server-security.md index 700084e2..467ec80b 100644 --- a/doc/md/Server-security.md +++ b/doc/md/Server-security.md @@ -1,10 +1,10 @@ ## php.ini PHP settings are defined in: -- a main configuration file, usually found under `/etc/php5/php.ini`; some distributions provide different configuration environments, e.g. - - `/etc/php5/php.ini` - used when running console scripts - - `/etc/php5/apache2/php.ini` - used when a client requests PHP resources from Apache - - `/etc/php5/php-fpm.conf` - used when PHP requests are proxied to PHP-FPM +- a main configuration file, usually found under `/etc/php/$php_version/php.ini`; some distributions provide different configuration environments, e.g. + - `/etc/php/$php_version/php.ini` - used when running console scripts + - `/etc/php/$php_version/apache2/php.ini` - used when a client requests PHP resources from Apache + - `/etc/php/$php_version/php-fpm.conf` - used when PHP requests are proxied to PHP-FPM - additional configuration files/entries, depending on the installed/enabled extensions: - `/etc/php/conf.d/xdebug.ini` -- cgit v1.2.3 From 1ea8aeef765d05e62c9766dd47dc4c417088f8c3 Mon Sep 17 00:00:00 2001 From: nodiscc Date: Mon, 9 Mar 2020 17:43:09 +0000 Subject: doc: fix php.ini path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Aurélien Tamisier --- doc/md/Server-security.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/md/Server-security.md b/doc/md/Server-security.md index 467ec80b..ea1b637d 100644 --- a/doc/md/Server-security.md +++ b/doc/md/Server-security.md @@ -2,7 +2,7 @@ PHP settings are defined in: - a main configuration file, usually found under `/etc/php/$php_version/php.ini`; some distributions provide different configuration environments, e.g. - - `/etc/php/$php_version/php.ini` - used when running console scripts + - `/etc/php/$php_version/cli/php.ini` - used when running console scripts - `/etc/php/$php_version/apache2/php.ini` - used when a client requests PHP resources from Apache - `/etc/php/$php_version/php-fpm.conf` - used when PHP requests are proxied to PHP-FPM - additional configuration files/entries, depending on the installed/enabled extensions: -- cgit v1.2.3 From 273453900afd7d118c0a369971f6c1fdbdd4f51d Mon Sep 17 00:00:00 2001 From: nodiscc Date: Mon, 9 Mar 2020 17:43:45 +0000 Subject: doc: use obvious placeholder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Aurélien Tamisier --- doc/md/Server-configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/md/Server-configuration.md b/doc/md/Server-configuration.md index bc6ac980..f9ea2ed2 100644 --- a/doc/md/Server-configuration.md +++ b/doc/md/Server-configuration.md @@ -187,7 +187,7 @@ http { ``` ```ini -# /etc/php/$php_version/fpm/php.ini +# /etc/php//fpm/php.ini [...] post_max_size = 10M -- cgit v1.2.3 From dbbcb0c6cf5c4efc1fa25d7e4f768c72c6eb156e Mon Sep 17 00:00:00 2001 From: nodiscc Date: Mon, 9 Mar 2020 17:44:12 +0000 Subject: doc: use , fix php.ini path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Aurélien Tamisier --- doc/md/Unit-tests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/md/Unit-tests.md b/doc/md/Unit-tests.md index 7eebf18e..91fd0526 100644 --- a/doc/md/Unit-tests.md +++ b/doc/md/Unit-tests.md @@ -30,7 +30,7 @@ $ aptitude install php-xdebug $ pacman -S xdebug ``` -Then add the following line to `/etc/php/php.ini`: +Then add the following line to `/etc/php//cli/php.ini`: ```ini zend_extension=xdebug.so -- cgit v1.2.3 From 2dd6ecb126ed5dd18d9c46ae892a440986239cab Mon Sep 17 00:00:00 2001 From: nodiscc Date: Sat, 11 Apr 2020 13:53:15 +0200 Subject: doc: composer update should actually be removed as it alters the Composer lock file --- doc/md/Unit-tests.md | 1 - 1 file changed, 1 deletion(-) (limited to 'doc') diff --git a/doc/md/Unit-tests.md b/doc/md/Unit-tests.md index 91fd0526..a9544656 100644 --- a/doc/md/Unit-tests.md +++ b/doc/md/Unit-tests.md @@ -15,7 +15,6 @@ You can either use: ```bash $ cd /path/to/shaarli $ composer install -$ composer update ``` ### Install Xdebug -- cgit v1.2.3