diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 71c61da..ac8dad1 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -20,7 +20,7 @@ jobs: name: "Generate CI matrix" uses: "glpi-project/plugin-ci-workflows/.github/workflows/generate-ci-matrix.yml@v1" with: - glpi-version: "11.0.x" + glpi-version: "12.0.x" ci: name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}" needs: "generate-ci-matrix" diff --git a/CHANGELOG.md b/CHANGELOG.md index 52eb2d6..44f1374 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,3 +6,5 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [unreleased] + +- GLPI 12 Compatibility \ No newline at end of file diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..da234c6 --- /dev/null +++ b/rector.php @@ -0,0 +1,50 @@ +withPaths([ + __DIR__ . '/front', + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + // uncomment to reach your current PHP version + // ->withPhpSets() + ->withTypeCoverageLevel(0) + ->withDeadCodeLevel(0) + ->withCodeQualityLevel(0); diff --git a/setup.php b/setup.php index b0dea80..9baf9ef 100644 --- a/setup.php +++ b/setup.php @@ -40,11 +40,11 @@ // Minimal GLPI version, inclusive /** @phpstan-ignore theCodingMachineSafe.function (safe to assume this isn't already defined) */ -define("PLUGIN_MOREOPTIONS_MIN_GLPI_VERSION", "11.0.0"); +define("PLUGIN_MOREOPTIONS_MIN_GLPI_VERSION", "12.0.0"); // Maximum GLPI version, exclusive /** @phpstan-ignore theCodingMachineSafe.function (safe to assume this isn't already defined) */ -define("PLUGIN_MOREOPTIONS_MAX_GLPI_VERSION", "11.0.99"); +define("PLUGIN_MOREOPTIONS_MAX_GLPI_VERSION", "12.0.99"); /** * Init hooks of the plugin. diff --git a/src/Config.php b/src/Config.php index 00c53e1..a3f52a9 100644 --- a/src/Config.php +++ b/src/Config.php @@ -46,8 +46,8 @@ class Config extends CommonDBTM { - public $dohistory = true; - public static $rightname = 'config'; + public bool $dohistory = true; + public static string $rightname = 'config'; public const CONFIG_PARENT = \Entity::CONFIG_PARENT; public static function getMenuName(): string { diff --git a/src/Controller.php b/src/Controller.php index 70ad728..10c6463 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -67,8 +67,8 @@ class Controller extends CommonDBTM { - public $dohistory = true; - public static $rightname = 'config'; + public bool $dohistory = true; + public static string $rightname = 'config'; private static bool $solution_check_done = false; public static function getTypeName($nb = 0): string { diff --git a/tests/e2e/fixtures/moreoptions_fixture.ts b/tests/e2e/fixtures/moreoptions_fixture.ts new file mode 100644 index 0000000..c9f5402 --- /dev/null +++ b/tests/e2e/fixtures/moreoptions_fixture.ts @@ -0,0 +1,34 @@ +/** + * ------------------------------------------------------------------------- + * MoreOptions plugin for GLPI + * ------------------------------------------------------------------------- + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2025 by the MoreOptions plugin team. + * @license MIT https://opensource.org/licenses/mit-license.php + * @link https://github.com/pluginsGLPI/moreoptions + * ------------------------------------------------------------------------- + */ + +// Re-export the core GLPI fixture so plugin specs share the same authenticated +// `test`/`expect` and the worker/profile/api helpers. +export * from '../../../../../tests/e2e/fixtures/glpi_fixture'; diff --git a/tests/e2e/pages/MoreOptionsConfigPage.ts b/tests/e2e/pages/MoreOptionsConfigPage.ts new file mode 100644 index 0000000..2011e18 --- /dev/null +++ b/tests/e2e/pages/MoreOptionsConfigPage.ts @@ -0,0 +1,72 @@ +/** + * ------------------------------------------------------------------------- + * MoreOptions plugin for GLPI + * ------------------------------------------------------------------------- + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2025 by the MoreOptions plugin team. + * @license MIT https://opensource.org/licenses/mit-license.php + * @link https://github.com/pluginsGLPI/moreoptions + * ------------------------------------------------------------------------- + */ + +import { Locator, Page } from '@playwright/test'; +// eslint-disable-next-line playwright/no-raw-locators +import { GlpiPage } from '../../../../../tests/e2e/pages/GlpiPage'; + +// The plugin registers a single tab (index 1) on the Entity item. +const CONFIG_TAB = 'GlpiPlugin\\Moreoptions\\Config$1'; + +export class MoreOptionsConfigPage extends GlpiPage +{ + public readonly save_button: Locator; + + public constructor(page: Page) + { + super(page); + + this.save_button = this.getButton('Save'); + } + + public async goto(entities_id: number): Promise + { + await this.page.goto( + `/front/entity.form.php?id=${entities_id}&forcetab=${CONFIG_TAB}` + ); + } + + /** + * The config fields are rendered without an associated