From bf0b7c97bde8b759eb7a658bb754f81ecdfdf9cc Mon Sep 17 00:00:00 2001 From: Benoit VIGNAL Date: Wed, 31 Dec 2025 15:17:46 +0100 Subject: [PATCH 1/2] chore: improve tests autoload + remove tools dep --- composer.json | 8 +++++--- plugin.sh | 2 ++ tests/bootstrap.php | 8 ++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 647270c..ae11edc 100644 --- a/composer.json +++ b/composer.json @@ -2,14 +2,16 @@ "require": { "php": ">=8.2" }, - "require-dev": { - "glpi-project/tools": "^0.8" - }, "config": { "optimize-autoloader": true, "platform": { "php": "8.2.99" }, "sort-packages": true + }, + "autoload-dev": { + "psr-4": { + "GlpiPlugin\\{NS_NAME}\\Tests\\": "tests/" + } } } diff --git a/plugin.sh b/plugin.sh index 7bff368..e4c2e02 100755 --- a/plugin.sh +++ b/plugin.sh @@ -48,6 +48,7 @@ fi NAME=$(echo $1|tr -dc '[[:alpha:]]') LNAME=$(echo "$NAME" | tr '[:upper:]' '[:lower:]') UNAME=$(echo "$NAME" | tr '[:lower:]' '[:upper:]') +NS_NAME=$(echo "$1" | sed -E 's/\b([a-z])/\U\1/g' | tr -dc '[[:alpha:]]') VERSION=$2 YEAR=$(date +%Y) @@ -85,6 +86,7 @@ sed \ -e "s/{NAME}/$NAME/g" \ -e "s/{LNAME}/$LNAME/g" \ -e "s/{UNAME}/$UNAME/g" \ + -e "s/{NS_NAME}/$NS_NAME/g" \ -e "s/{VERSION}/$VERSION/g" \ -e "s/{YEAR}/$YEAR/g" \ -i setup.php hook.php $LNAME.xml tools/HEADER README.md Makefile .github/workflows/continuous-integration.yml tests/bootstrap.php composer.json rector.php diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 1cc332a..c14d44f 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -31,8 +31,12 @@ * ------------------------------------------------------------------------- */ +$current_plugin_folder = basename(realpath(__DIR__ . '/../')); + require __DIR__ . '/../../../tests/bootstrap.php'; +require dirname(__DIR__) . '/vendor/autoload.php'; -if (!Plugin::isPluginActive("{LNAME}")) { - throw new RuntimeException("Plugin {LNAME} is not active in the test database"); +if (!Plugin::isPluginActive($current_plugin_folder)) { + echo("Plugin $current_plugin_folder is not active in the test database" . PHP_EOL); + die(); } From 95e286f52a53a697c9a35babdf8e497c1d2ac934 Mon Sep 17 00:00:00 2001 From: Benoit VIGNAL Date: Wed, 31 Dec 2025 15:31:35 +0100 Subject: [PATCH 2/2] dx: display folder creation path --- plugin.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin.sh b/plugin.sh index e4c2e02..ab7b61f 100755 --- a/plugin.sh +++ b/plugin.sh @@ -95,3 +95,5 @@ sed \ sed -i '/^[[:space:]]*composer\.lock[[:space:]]*$/d' .gitignore popd > /dev/null + +echo -e "\033[0;32mPlugin $NAME created under $DEST\033[0m"