From ef8ade5d203ba9ca4dff33f625f554abb05daa48 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Wed, 17 Dec 2025 18:36:00 +0100 Subject: [PATCH 1/3] :memo: Update unit tests documentation --- tests/php-unit-tests/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/php-unit-tests/README.md b/tests/php-unit-tests/README.md index 4cc175be1..d098ddcc9 100644 --- a/tests/php-unit-tests/README.md +++ b/tests/php-unit-tests/README.md @@ -2,9 +2,6 @@ Documentation on creating and maintaining tests in iTop. - - - ## Prerequisites ### PHPUnit configuration file @@ -78,7 +75,8 @@ Example : $oTagData->DBDelete(); ``` -Warning : when the condition is met the test is finished and following code will be ignored ! +> [!WARNING] +> When the condition is met the test is finished and following code will be ignored ! Another way to do is using try/catch blocks, for example : ```php From 4f1f144c5165ae68b0eca12ae52a9269f787b1a9 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Wed, 17 Dec 2025 22:04:49 +0100 Subject: [PATCH 2/3] =?UTF-8?q?N=C2=B06644=20-=20PHP=20Static=20Analysis:?= =?UTF-8?q?=20Update=20configuration=20to:=20=20-=20Ignore=20compiled=20fo?= =?UTF-8?q?lders=20other=20than=20"env-production"=20=20-=20Ignore=20Lempa?= =?UTF-8?q?r.php=20as=20its=20content=20isn't=20valid=20PHP=20and=20it=20w?= =?UTF-8?q?on't=20be=20included=20in=20the=20baseline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../php-static-analysis/config/base.dist.neon | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/php-static-analysis/config/base.dist.neon b/tests/php-static-analysis/config/base.dist.neon index 804c6f089..827e7022f 100644 --- a/tests/php-static-analysis/config/base.dist.neon +++ b/tests/php-static-analysis/config/base.dist.neon @@ -5,8 +5,8 @@ includes: parameters: level: 0 - #phpVersion: null # Explicitly commented as we rather use the detected version from the above include (`php-includes/target-php-version.php`) - editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%' # Open in PHPStorm asit is Combodo's default IDE + #phpVersion: null # Explicitly commented as we rather use the detected version from the above include (`php-includes/target-php-version.php`) + editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%' # Open in PHPStorm as it's Combodo's default IDE bootstrapFiles: - ../../../approot.inc.php - ../../../bootstrap.inc.php @@ -22,11 +22,19 @@ parameters: - ../../../lib # Irrelevant as we only want to analyze our codebase - ../../../node_modules # Irrelevant as we only want to analyze our codebase analyseAndScan: - #- ../../../data # Left and commented on purpose to show that we want to analyse the generated cache files - # Note 1: We can analyse these folders as if a PHP file requires another PHP element declared in an XML file, it won't find it. So we rely only on `env-production` + # This file generates "unignorable errors" for the baseline due to its format, so we don't have any other choice than to exclude it. + # But mind that it will prevent PHPStan from warning us about PHP syntax errors in this file. + - ../../../core/oql/build/PHP/Lempar.php + + #- ../../../data # Left and commented on purpose to show that we want to analyse the generated cache files + + # Note 1: We can't analyse these folders as if a PHP file requires another PHP element declared in an XML file, it won't find it. So we rely only on `env-production` # Note 2: Only the options selected during the setup will be analysed correctly in `env-production`. For unselected options, we still want to ignore them during the analysis as they would only give a false sentiment of security as their XML PHP classes / snippets / etc would not be tested. - ../../../data/production-modules # Irrelevent as it will already be in `env-production` (for local run only, not useful in the CI) - - ../../../datamodels # Irrelevent as it will already be in `env-production` - - ../../../extensions # Irrelevent as it will already be in `env-production` (for local run only, not useful in the CI) - - ../../../tests # Exclude tests for now - - ../../../toolkit # Exlclude toolkit for now + - ../../../datamodels # Irrelevent as it will already be in `env-production` + - ../../../extensions # Irrelevent as it will already be in `env-production` (for local run only, not useful in the CI) + - ../../../env-php-unit-tests # Irrelevant as it will either already be in `env-production` or might be desynchronized from `env-production` + - ../../../env-toolkit # Irrelevent as it will either already be in `env-production` or might be desynchronized from `env-production` (for local run only, not useful in the CI) + + - ../../../tests # Exclude tests for now + - ../../../toolkit # Exlclude toolkit for now From f9db40534310aaed126e36e953c2ee454faa7380 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Wed, 17 Dec 2025 22:21:43 +0100 Subject: [PATCH 3/3] =?UTF-8?q?N=C2=B06644=20-=20PHP=20Static=20Analysis:?= =?UTF-8?q?=20Update=20PHPStan=20to=20v2.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/php-static-analysis/composer.json | 2 +- tests/php-static-analysis/composer.lock | 23 ++++++------------- .../php-static-analysis/config/base.dist.neon | 16 ++++++------- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/tests/php-static-analysis/composer.json b/tests/php-static-analysis/composer.json index 79097c0b3..1cf76a892 100644 --- a/tests/php-static-analysis/composer.json +++ b/tests/php-static-analysis/composer.json @@ -1,5 +1,5 @@ { "require": { - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "^2.1" } } diff --git a/tests/php-static-analysis/composer.lock b/tests/php-static-analysis/composer.lock index 4e52e3fb3..36d8e1005 100644 --- a/tests/php-static-analysis/composer.lock +++ b/tests/php-static-analysis/composer.lock @@ -4,24 +4,19 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "14812c2a05a5972f00f9d67abbd710a9", + "content-hash": "cc6d7580a5e98236d68d8b91de9ddebb", "packages": [ { "name": "phpstan/phpstan", - "version": "1.10.26", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "5d660cbb7e1b89253a47147ae44044f49832351f" - }, + "version": "2.1.33", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/5d660cbb7e1b89253a47147ae44044f49832351f", - "reference": "5d660cbb7e1b89253a47147ae44044f49832351f", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9e800e6bee7d5bd02784d4c6069b48032d16224f", + "reference": "9e800e6bee7d5bd02784d4c6069b48032d16224f", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -60,13 +55,9 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2023-07-19T12:44:37+00:00" + "time": "2025-12-05T10:24:31+00:00" } ], "packages-dev": [], @@ -77,5 +68,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/tests/php-static-analysis/config/base.dist.neon b/tests/php-static-analysis/config/base.dist.neon index 827e7022f..eaf30b872 100644 --- a/tests/php-static-analysis/config/base.dist.neon +++ b/tests/php-static-analysis/config/base.dist.neon @@ -26,15 +26,15 @@ parameters: # But mind that it will prevent PHPStan from warning us about PHP syntax errors in this file. - ../../../core/oql/build/PHP/Lempar.php - #- ../../../data # Left and commented on purpose to show that we want to analyse the generated cache files + #- ../../../data # Left and commented on purpose to show that we want to analyse the generated cache files # Note 1: We can't analyse these folders as if a PHP file requires another PHP element declared in an XML file, it won't find it. So we rely only on `env-production` # Note 2: Only the options selected during the setup will be analysed correctly in `env-production`. For unselected options, we still want to ignore them during the analysis as they would only give a false sentiment of security as their XML PHP classes / snippets / etc would not be tested. - - ../../../data/production-modules # Irrelevent as it will already be in `env-production` (for local run only, not useful in the CI) - - ../../../datamodels # Irrelevent as it will already be in `env-production` - - ../../../extensions # Irrelevent as it will already be in `env-production` (for local run only, not useful in the CI) - - ../../../env-php-unit-tests # Irrelevant as it will either already be in `env-production` or might be desynchronized from `env-production` - - ../../../env-toolkit # Irrelevent as it will either already be in `env-production` or might be desynchronized from `env-production` (for local run only, not useful in the CI) + - ../../../data/production-modules (?) # Irrelevent as it will already be in `env-production` (for local run only, not useful in the CI) + - ../../../datamodels # Irrelevent as it will already be in `env-production` + - ../../../extensions # Irrelevent as it will already be in `env-production` (for local run only, not useful in the CI) + - ../../../env-php-unit-tests (?) # Irrelevant as it will either already be in `env-production` or might be desynchronized from `env-production` + - ../../../env-toolkit (?) # Irrelevent as it will either already be in `env-production` or might be desynchronized from `env-production` (for local run only, not useful in the CI) - - ../../../tests # Exclude tests for now - - ../../../toolkit # Exlclude toolkit for now + - ../../../tests (?) # Exclude tests for now + - ../../../toolkit (?) # Exlclude toolkit for now