Skip to content

Commit 750e6d2

Browse files
SebSepttrasher
andcommitted
update tests documentation (#162)
* Update sourcecode testing section * Update linting section * nfo about launching tests "as in ci" + note about phpunit * Update source/sourcecode.rst Co-authored-by: Johan Cwiklinski <trasher@x-tnd.be> --------- Co-authored-by: Sebastien Monterisi <smonterisi@teclib.com> Co-authored-by: Johan Cwiklinski <trasher@x-tnd.be>
1 parent 21099a0 commit 750e6d2

File tree

2 files changed

+9
-31
lines changed

2 files changed

+9
-31
lines changed

source/codingstandards.rst

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -245,33 +245,9 @@ Examples:
245245
Checking standards
246246
------------------
247247

248-
In order to check standards are respected, we provide a defaut configuration for `PHP CodeSniffer <http://pear.php.net/package/PHP_CodeSniffer>`_ rules. From the GLPI directory, just run:
248+
Linting (checking and fixing coding standards) is a good way to ensure code quality and consistency of the code base.
249+
This is done using [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer), [PHPStan](https://phpstan.org/), [ESLint](https://eslint.org/), [Stylelint](https://stylelint.io/) and [TwigCS](https://github.com/friendsoftwig/twigcs).
249250

250-
.. code-block::
251-
252-
phpcs .
253-
254-
If the above command does not provide any output, then, all is OK :)
255-
256-
An example error output would looks like:
257-
258-
.. code-block:: bash
259-
260-
phpcs .
261-
262-
FILE: /var/www/webapps/glpi/tests/HtmlTest.php
263-
----------------------------------------------------------------------
264-
FOUND 3 ERRORS AFFECTING 3 LINES
265-
----------------------------------------------------------------------
266-
40 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
267-
| | 3
268-
59 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
269-
| | 3
270-
64 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
271-
| | 3
272-
273-
To automatically fix most of the issues, use `phpcbf`, it will per default rely on default configuration:
274-
275-
.. code-block::
276-
277-
phpcbf .
251+
This can run the tasks using Docker, on your local host use `./tests/run_tests.sh lint` to proceed to all linting tasks, or use a scoped task, `./tests/run_tests.sh lint_php` to proceed to PHP linting only for example.
252+
All possible lintings are listed in the `./tests/run_tests.sh` script.
253+
For faster action you can run the scripts on your local machine or Docker development container using `node_modules/.bin/eslint . && echo "ESLint found no errors"` for example. You can find all the commands in [`.github/actions` directory](https://github.com/glpi-project/glpi/tree/main/.github/actions).

source/sourcecode.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ Those branches are created when a new major or intermediate version is released.
3737
Testing
3838
-------
3939

40-
There are more and more unit tests in GLPI; we use the `atoum unit tests framework <http://atoum.org>`_.
40+
Testing is a very important part of the development process.
41+
The reference for tests is the `GitHub CI <https://github.com/glpi-project/glpi/blob/main/.github/workflows/ci.yml>`_.
42+
The easier way to proceed with testing is to use the provided test script `run_tests.sh <https://github.com/glpi-project/glpi/blob/main/tests/run_tests.sh>`_ which uses Docker and bootstrap everything needed.
4143

4244
Every proposal **must** contains unit tests; for new features as well as bugfixes. For the bugfixes; this is not a strict requirement if this is part of code that is not tested at all yet. See the :ref:`unit testing section <unittests>` at the bottom of the page.
4345

@@ -260,7 +262,7 @@ Unit testing (and functional testing)
260262

261263
A note for the purists... In GLPI, there are both unit and functional tests; without real distinction ;-)
262264

263-
We use the `atoum unit tests framework <http://atoum.org>`_ for PHP tests; see `GLPI website if you wonder why <http://glpi-project.org/spip.php?breve375>`_.
265+
We use `PHPUnit <https://phpunit.de>`_ for tests.
264266
`atoum`'s documentation in available at: http://docs.atoum.org
265267

266268
For JavaScript tests, GLPI uses the Jest testing framework.

0 commit comments

Comments
 (0)