Skip to content

Commit d3221bc

Browse files
authored
Remove glpi tools dep
1 parent 8c19c1a commit d3221bc

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
"require": {
33
"php": ">=8.2"
44
},
5-
"require-dev": {
6-
"glpi-project/tools": "^0.8"
7-
},
85
"config": {
96
"optimize-autoloader": true,
107
"platform": {
118
"php": "8.2.99"
129
},
1310
"sort-packages": true
11+
},
12+
"autoload-dev": {
13+
"psr-4": {
14+
"GlpiPlugin\\{NS_NAME}\\Tests\\": "tests/"
15+
}
1416
}
1517
}

plugin.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ fi
4848
NAME=$(echo $1|tr -dc '[[:alpha:]]')
4949
LNAME=$(echo "$NAME" | tr '[:upper:]' '[:lower:]')
5050
UNAME=$(echo "$NAME" | tr '[:lower:]' '[:upper:]')
51+
NS_NAME=$(echo "$1" | sed -E 's/\b([a-z])/\U\1/g' | tr -dc '[[:alpha:]]')
5152
VERSION=$2
5253
YEAR=$(date +%Y)
5354

@@ -85,6 +86,7 @@ sed \
8586
-e "s/{NAME}/$NAME/g" \
8687
-e "s/{LNAME}/$LNAME/g" \
8788
-e "s/{UNAME}/$UNAME/g" \
89+
-e "s/{NS_NAME}/$NS_NAME/g" \
8890
-e "s/{VERSION}/$VERSION/g" \
8991
-e "s/{YEAR}/$YEAR/g" \
9092
-i setup.php hook.php $LNAME.xml tools/HEADER README.md Makefile .github/workflows/continuous-integration.yml tests/bootstrap.php composer.json rector.php
@@ -93,3 +95,5 @@ sed \
9395
sed -i '/^[[:space:]]*composer\.lock[[:space:]]*$/d' .gitignore
9496

9597
popd > /dev/null
98+
99+
echo -e "\033[0;32mPlugin $NAME created under $DEST\033[0m"

tests/bootstrap.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@
3131
* -------------------------------------------------------------------------
3232
*/
3333

34+
$current_plugin_folder = basename(realpath(__DIR__ . '/../'));
35+
3436
require __DIR__ . '/../../../tests/bootstrap.php';
37+
require dirname(__DIR__) . '/vendor/autoload.php';
3538

36-
if (!Plugin::isPluginActive("{LNAME}")) {
37-
throw new RuntimeException("Plugin {LNAME} is not active in the test database");
39+
if (!Plugin::isPluginActive($current_plugin_folder)) {
40+
throw new RuntimeException("Plugin $current_plugin_folder is not active in the test database");
3841
}

0 commit comments

Comments
 (0)