From 587c662d881187b93de95f4ef765cc378c71e257 Mon Sep 17 00:00:00 2001 From: Lainow Date: Fri, 2 Aug 2024 11:57:40 +0200 Subject: [PATCH 01/20] Fix history task message --- inc/ticket.class.php | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/inc/ticket.class.php b/inc/ticket.class.php index fda875c..88c016d 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -92,20 +92,6 @@ function ($carry, $type) use ($item) { 'assign' => $config['remove_delete_assign_supplier_btn'], ], ]; - - if (!isset($item->input['_actors'])) { - $item->input['_actors'] = $item->fields['_actors'] ?? []; - } else { - // Iteration through actor types and verification of deletion rights - foreach ($ticket_actors as $type => $actors) { - foreach ($actors as $actor) { - // If the actor has been deleted and deletion is forbidden, it is readjusted to simulate a non-deletion - if ($deletion_rights[$actor['itemtype']][$type] == 0) { - $item->input['_actors'][$type][] = $actor; - } - } - } - } } if (!isset($item->input['actortype'])) { $groups = new Group_Ticket(); From f31f934c640ab2d3ca47526cf6518d8306391cbc Mon Sep 17 00:00:00 2001 From: Lainow Date: Mon, 5 Aug 2024 11:37:20 +0200 Subject: [PATCH 02/20] Add Units tests --- composer.json | 1 + composer.lock | 2039 ++++++++++++++++++++++++++++++++--- phpunit.xml | 7 + tests/autoload.php | 102 ++ tests/units/TaskMessage.php | 105 ++ 5 files changed, 2105 insertions(+), 149 deletions(-) create mode 100644 phpunit.xml create mode 100644 tests/autoload.php create mode 100644 tests/units/TaskMessage.php diff --git a/composer.json b/composer.json index f2694ca..ba0cd71 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,7 @@ "phpstan/extension-installer": "^1.4", "phpstan/phpstan": "^1.11", "phpstan/phpstan-deprecation-rules": "^1.2", + "phpunit/phpunit": "^9.6", "squizlabs/php_codesniffer": "^3.10" }, "config": { diff --git a/composer.lock b/composer.lock index eeb73bf..5ff42c4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,79 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "aef119cc48941a0b5f6903da82850dc9", + "content-hash": "af349a56b649fbd5c677dab0df5808b8", "packages": [], "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9 || ^11", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.30 || ^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.5.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2022-12-30T00:15:36+00:00" + }, { "name": "glpi-project/tools", "version": "0.7.3", @@ -42,284 +112,1905 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "GPL-3.0-or-later" + "GPL-3.0-or-later" + ], + "authors": [ + { + "name": "Teclib'", + "email": "glpi@teclib.com", + "homepage": "http://teclib-group.com" + } + ], + "description": "Various tools for GLPI and its plugins", + "keywords": [ + "glpi", + "plugins", + "tools" + ], + "support": { + "issues": "https://github.com/glpi-project/tools/issues", + "source": "https://github.com/glpi-project/tools" + }, + "time": "2024-06-20T08:36:22+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.12.0", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3 <3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2024-06-12T14:39:25+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v5.1.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/683130c2ff8c2739f4822ff7ac5c873ec529abd1", + "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "php": ">=7.4" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v5.1.0" + }, + "time": "2024-07-01T20:03:41+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "54750ef60c58e43759730615a392c31c80e23176" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" + }, + { + "name": "phar-io/version", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" + }, + { + "name": "php-parallel-lint/php-parallel-lint", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", + "reference": "6db563514f27e19595a19f45a4bf757b6401194e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/6db563514f27e19595a19f45a4bf757b6401194e", + "reference": "6db563514f27e19595a19f45a4bf757b6401194e", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=5.3.0" + }, + "replace": { + "grogy/php-parallel-lint": "*", + "jakub-onderka/php-parallel-lint": "*" + }, + "require-dev": { + "nette/tester": "^1.3 || ^2.0", + "php-parallel-lint/php-console-highlighter": "0.* || ^1.0", + "squizlabs/php_codesniffer": "^3.6" + }, + "suggest": { + "php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet" + }, + "bin": [ + "parallel-lint" + ], + "type": "library", + "autoload": { + "classmap": [ + "./src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Jakub Onderka", + "email": "ahoj@jakubonderka.cz" + } + ], + "description": "This tool checks the syntax of PHP files about 20x faster than serial check.", + "homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint", + "keywords": [ + "lint", + "static analysis" + ], + "support": { + "issues": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/issues", + "source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/v1.4.0" + }, + "time": "2024-03-27T12:14:49+00:00" + }, + { + "name": "phpstan/extension-installer", + "version": "1.4.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "f6b87faf9fc7978eab2f7919a8760bc9f58f9203" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f6b87faf9fc7978eab2f7919a8760bc9f58f9203", + "reference": "f6b87faf9fc7978eab2f7919a8760bc9f58f9203", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.4.1" + }, + "time": "2024-06-10T08:20:49+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "1.11.5", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "490f0ae1c92b082f154681d7849aee776a7c1443" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/490f0ae1c92b082f154681d7849aee776a7c1443", + "reference": "490f0ae1c92b082f154681d7849aee776a7c1443", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2024-06-17T15:10:54+00:00" + }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "fa8cce7720fa782899a0aa97b6a41225d1bb7b26" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/fa8cce7720fa782899a0aa97b6a41225d1bb7b26", + "reference": "fa8cce7720fa782899a0aa97b6a41225d1bb7b26", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.11" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.2.0" + }, + "time": "2024-04-20T06:39:48+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "9.2.31", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/48c34b5d8d983006bd2adc2d0de92963b9155965", + "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-text-template": "^2.0.2", + "sebastian/code-unit-reverse-lookup": "^2.0.2", + "sebastian/complexity": "^2.0", + "sebastian/environment": "^5.1.2", + "sebastian/lines-of-code": "^1.0.3", + "sebastian/version": "^3.0.1", + "theseer/tokenizer": "^1.2.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.31" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:37:42+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "3.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-12-02T12:48:52+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:16:10+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "9.6.20", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "49d7820565836236411f5dc002d16dd689cde42f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/49d7820565836236411f5dc002d16dd689cde42f", + "reference": "49d7820565836236411f5dc002d16dd689cde42f", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.5.0 || ^2", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.12.0", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", + "php": ">=7.3", + "phpunit/php-code-coverage": "^9.2.31", + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", + "sebastian/comparator": "^4.0.8", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.6", + "sebastian/global-state": "^5.0.7", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", + "sebastian/version": "^3.0.2" + }, + "suggest": { + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.6-dev" + } + }, + "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.20" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "time": "2024-07-10T11:45:39+00:00" + }, + { + "name": "psr/container", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/1.1.2" + }, + "time": "2021-11-05T16:50:12+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:27:43+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:08:54+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:30:19+00:00" + }, + { + "name": "sebastian/comparator", + "version": "4.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2022-09-14T12:41:17+00:00" + }, + { + "name": "sebastian/complexity", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T06:19:30+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:30:58+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:03:51+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:33:00+00:00" + }, + { + "name": "sebastian/global-state", + "version": "5.0.7", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.7" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:35:11+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T06:20:34+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" ], "authors": [ { - "name": "Teclib'", - "email": "glpi@teclib.com", - "homepage": "http://teclib-group.com" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" } ], - "description": "Various tools for GLPI and its plugins", - "keywords": [ - "glpi", - "plugins", - "tools" - ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", "support": { - "issues": "https://github.com/glpi-project/tools/issues", - "source": "https://github.com/glpi-project/tools" + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" }, - "time": "2024-06-20T08:36:22+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:12:34+00:00" }, { - "name": "php-parallel-lint/php-parallel-lint", - "version": "v1.4.0", + "name": "sebastian/object-reflector", + "version": "2.0.4", "source": { "type": "git", - "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", - "reference": "6db563514f27e19595a19f45a4bf757b6401194e" + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/6db563514f27e19595a19f45a4bf757b6401194e", - "reference": "6db563514f27e19595a19f45a4bf757b6401194e", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", "shasum": "" }, "require": { - "ext-json": "*", - "php": ">=5.3.0" - }, - "replace": { - "grogy/php-parallel-lint": "*", - "jakub-onderka/php-parallel-lint": "*" + "php": ">=7.3" }, "require-dev": { - "nette/tester": "^1.3 || ^2.0", - "php-parallel-lint/php-console-highlighter": "0.* || ^1.0", - "squizlabs/php_codesniffer": "^3.6" - }, - "suggest": { - "php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet" + "phpunit/phpunit": "^9.3" }, - "bin": [ - "parallel-lint" - ], "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, "autoload": { "classmap": [ - "./src/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-2-Clause" + "BSD-3-Clause" ], "authors": [ { - "name": "Jakub Onderka", - "email": "ahoj@jakubonderka.cz" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" } ], - "description": "This tool checks the syntax of PHP files about 20x faster than serial check.", - "homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint", - "keywords": [ - "lint", - "static analysis" - ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", "support": { - "issues": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/issues", - "source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/v1.4.0" + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" }, - "time": "2024-03-27T12:14:49+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:14:26+00:00" }, { - "name": "phpstan/extension-installer", - "version": "1.4.1", + "name": "sebastian/recursion-context", + "version": "4.0.5", "source": { "type": "git", - "url": "https://github.com/phpstan/extension-installer.git", - "reference": "f6b87faf9fc7978eab2f7919a8760bc9f58f9203" + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f6b87faf9fc7978eab2f7919a8760bc9f58f9203", - "reference": "f6b87faf9fc7978eab2f7919a8760bc9f58f9203", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", "shasum": "" }, "require": { - "composer-plugin-api": "^2.0", - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.9.0" + "php": ">=7.3" }, "require-dev": { - "composer/composer": "^2.0", - "php-parallel-lint/php-parallel-lint": "^1.2.0", - "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + "phpunit/phpunit": "^9.3" }, - "type": "composer-plugin", + "type": "library", "extra": { - "class": "PHPStan\\ExtensionInstaller\\Plugin" + "branch-alias": { + "dev-master": "4.0-dev" + } }, "autoload": { - "psr-4": { - "PHPStan\\ExtensionInstaller\\": "src/" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], - "description": "Composer plugin for automatic installation of PHPStan extensions", + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { - "issues": "https://github.com/phpstan/extension-installer/issues", - "source": "https://github.com/phpstan/extension-installer/tree/1.4.1" + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" }, - "time": "2024-06-10T08:20:49+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:07:39+00:00" }, { - "name": "phpstan/phpstan", - "version": "1.11.5", + "name": "sebastian/resource-operations", + "version": "3.0.4", "source": { "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "490f0ae1c92b082f154681d7849aee776a7c1443" + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/490f0ae1c92b082f154681d7849aee776a7c1443", - "reference": "490f0ae1c92b082f154681d7849aee776a7c1443", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": ">=7.3" }, - "conflict": { - "phpstan/phpstan-shim": "*" + "require-dev": { + "phpunit/phpunit": "^9.0" }, - "bin": [ - "phpstan", - "phpstan.phar" - ], "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, "autoload": { - "files": [ - "bootstrap.php" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], - "description": "PHPStan - PHP Static Analysis Tool", - "keywords": [ - "dev", - "static analysis" + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { - "docs": "https://phpstan.org/user-guide/getting-started", - "forum": "https://github.com/phpstan/phpstan/discussions", - "issues": "https://github.com/phpstan/phpstan/issues", - "security": "https://github.com/phpstan/phpstan/security/policy", - "source": "https://github.com/phpstan/phpstan-src" + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" }, "funding": [ { - "url": "https://github.com/ondrejmirtes", - "type": "github" - }, - { - "url": "https://github.com/phpstan", + "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2024-06-17T15:10:54+00:00" + "time": "2024-03-14T16:00:52+00:00" }, { - "name": "phpstan/phpstan-deprecation-rules", - "version": "1.2.0", + "name": "sebastian/type", + "version": "3.2.1", "source": { "type": "git", - "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", - "reference": "fa8cce7720fa782899a0aa97b6a41225d1bb7b26" + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/fa8cce7720fa782899a0aa97b6a41225d1bb7b26", - "reference": "fa8cce7720fa782899a0aa97b6a41225d1bb7b26", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.11" + "php": ">=7.3" }, "require-dev": { - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^1.0", "phpunit/phpunit": "^9.5" }, - "type": "phpstan-extension", + "type": "library", "extra": { - "phpstan": { - "includes": [ - "rules.neon" - ] + "branch-alias": { + "dev-master": "3.2-dev" } }, "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], - "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", "support": { - "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", - "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.2.0" + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" }, - "time": "2024-04-20T06:39:48+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:13:03+00:00" }, { - "name": "psr/container", - "version": "1.1.2", + "name": "sebastian/version", + "version": "3.0.2", "source": { "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c6c1022351a901512170118436c764e473f6de8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", "shasum": "" }, "require": { - "php": ">=7.4.0" + "php": ">=7.3" }, "type": "library", - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" } }, + "autoload": { + "classmap": [ + "src/" + ] + }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", "support": { - "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" }, - "time": "2021-11-05T16:50:12+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:39:44+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -1210,6 +2901,56 @@ ], "time": "2024-06-28T09:20:55+00:00" }, + { + "name": "theseer/tokenizer", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:36:25+00:00" + }, { "name": "twig/twig", "version": "v3.10.3", diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..2d75f57 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,7 @@ + + + + tests/units + + + diff --git a/tests/autoload.php b/tests/autoload.php new file mode 100644 index 0000000..0a1ee5b --- /dev/null +++ b/tests/autoload.php @@ -0,0 +1,102 @@ + $constant_value) { + if ( + preg_match('/^GLPI_[\w]+_DIR$/', $constant_name) + && preg_match('/^' . preg_quote(GLPI_VAR_DIR, '/') . '\//', $constant_value) + ) { + is_dir($constant_value) or mkdir($constant_value, 0755, true); + } +} + +//init cache +if (file_exists(GLPI_CONFIG_DIR . DIRECTORY_SEPARATOR . CacheManager::CONFIG_FILENAME)) { + // Use configured cache for cache tests + $cache_manager = new CacheManager(); + $GLPI_CACHE = $cache_manager->getCoreCacheInstance(); +} else { + // Use "in-memory" cache for other tests + $GLPI_CACHE = new SimpleCache(new ArrayAdapter()); +} + +global $PLUGIN_HOOKS; + +include_once GLPI_ROOT . 'inc/includes.php'; +include_once GLPI_ROOT . '/plugins/escalade/vendor/autoload.php'; +include_once GLPI_ROOT . '/plugins/escalade/setup.php'; +include_once GLPI_ROOT . '/plugins/escalade/hook.php'; + +$auth = new Auth(); +$user = new User(); +$auth->auth_succeded = true; +$user->getFromDB(2); +$auth->user = $user; +Session::init($auth); +Session::initEntityProfiles(2); +Session::changeProfile(4); +plugin_escalade_install(); +plugin_init_escalade(); +$plugins = new Plugin(); +if (!$plugins->getFromDBbyDir('escalade')) { + $plugins->add([ + 'directory' => 'escalade', + 'name' => 'escalade', + 'version' => PLUGIN_ESCALADE_VERSION, + 'state' => Plugin::ACTIVATED, + ]); +} + +if (!file_exists(GLPI_LOG_DIR . '/php-errors.log')) { + file_put_contents(GLPI_LOG_DIR . '/php-errors.log', ''); +} + +if (!file_exists(GLPI_LOG_DIR . '/sql-errors.log')) { + file_put_contents(GLPI_LOG_DIR . '/sql-errors.log', ''); +} + +// @codingStandardsIgnoreStart +class GlpitestPHPerror extends \Exception +{ +} +class GlpitestPHPwarning extends \Exception +{ +} +class GlpitestPHPnotice extends \Exception +{ +} +class GlpitestSQLError extends \Exception +{ +} +// @codingStandardsIgnoreEnd diff --git a/tests/units/TaskMessage.php b/tests/units/TaskMessage.php new file mode 100644 index 0000000..3bfbeba --- /dev/null +++ b/tests/units/TaskMessage.php @@ -0,0 +1,105 @@ +add([ + 'name' => 'Test', + 'content' => '', + ]); + + $group_test = new Group(); + $group_test->add([ + 'name' => 'Test Group', + ]); + + $group_test_2 = new Group(); + $group_test_2->add([ + 'name' => 'Test Group 2', + ]); + + return [ + [ + 'expected' => [ + 'groups_count' => 0, + 'tasks_count' => 0, + 'last_task_content' => null, + 'ticket_id' => $ticket->getID(), + 'group_id' => null, + ], + 'inputs' => [ + 'id' => $ticket->getID(), + ], + ], + [ + 'expected' => [ + 'groups_count' => 1, + 'tasks_count' => 1, + 'last_task_content' => 'Escalation to the group Test Group.', + 'ticket_id' => $ticket->getID(), + 'group_id' => $group_test->getID(), + ], + 'inputs' => [ + 'id' => $ticket->getID(), + '_actors' => [ + 'assign' => [ + [ + 'items_id' => $group_test->getID(), + 'itemtype' => 'Group' + ], + ], + ], + ], + ], + [ + 'expected' => [ + 'groups_count' => 1, + 'tasks_count' => 2, + 'last_task_content' => 'Escalation to the group Test Group 2.', + 'ticket_id' => $ticket->getID(), + 'group_id' => $group_test_2->getID(), + ], + 'inputs' => [ + 'id' => $ticket->getID(), + '_actors' => [ + 'assign' => [ + [ + 'items_id' => $group_test->getID(), + 'itemtype' => 'Group' + ], + [ + 'items_id' => $group_test_2->getID(), + 'itemtype' => 'Group' + ], + ], + ], + ], + ], + ]; + } + + /** + * @dataProvider dataTestEscalationTaskGroup + */ + public function testEscalationTaskGroup($expected, $inputs) + { + $ticket = new Ticket(); + $ticket->update($inputs); + + $ticket_group = new Group_Ticket(); + $t_groups = $ticket_group->find(['tickets_id' => $expected['ticket_id']]); + $this->assertEquals(count($t_groups), $expected['groups_count']); + + $ticket_task = new TicketTask(); + $t_tasks = $ticket_task->find(['tickets_id' => $expected['ticket_id']]); + $this->assertEquals(count($t_tasks), $expected['tasks_count']); + $last_task = end($t_tasks); + if ($last_task) { + $this->assertEquals($last_task['content'], $expected['last_task_content']); + } + } +} From 9a1ec1c0be38d0a761cec6febc688bc69cc4230f Mon Sep 17 00:00:00 2001 From: Lainow Date: Mon, 5 Aug 2024 13:46:00 +0200 Subject: [PATCH 03/20] Fix header --- .gitignore | 3 ++- tests/autoload.php | 28 ++++++++++++++++++++++++++++ tests/units/TaskMessage.php | 28 ++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f033123..96b559d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ dist/ vendor/ .gh_token *.min.* - +.phpunit.result.cache +tests/files/ diff --git a/tests/autoload.php b/tests/autoload.php index 0a1ee5b..b0c39b9 100644 --- a/tests/autoload.php +++ b/tests/autoload.php @@ -1,5 +1,33 @@ . + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2015-2023 by Escalade plugin team. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/escalade + * ------------------------------------------------------------------------- + */ + use Glpi\Cache\CacheManager; use Glpi\Cache\SimpleCache; use Symfony\Component\Cache\Adapter\ArrayAdapter; diff --git a/tests/units/TaskMessage.php b/tests/units/TaskMessage.php index 3bfbeba..ad57bf5 100644 --- a/tests/units/TaskMessage.php +++ b/tests/units/TaskMessage.php @@ -1,5 +1,33 @@ . + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2015-2023 by Escalade plugin team. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/escalade + * ------------------------------------------------------------------------- + */ + use PHPUnit\Framework\TestCase; class TaskMessage extends TestCase From 506cdd5674dd24bbaecf980b4964a707daf0bd06 Mon Sep 17 00:00:00 2001 From: LAUNAY Samuel <107540223+Lainow@users.noreply.github.com> Date: Mon, 5 Aug 2024 15:13:55 +0200 Subject: [PATCH 04/20] Apply suggestions from code review Co-authored-by: Romain Lecouvreur <102067890+RomainLvr@users.noreply.github.com> --- tests/autoload.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/autoload.php b/tests/autoload.php index b0c39b9..4b5b46c 100644 --- a/tests/autoload.php +++ b/tests/autoload.php @@ -51,6 +51,10 @@ define('TU_USER', '_test_user'); define('TU_PASS', 'PhpUnit_4'); +/** + * @var array $CFG_GLPI + * @var \Psr\SimpleCache\CacheInterface $GLPI_CACHE + */ global $CFG_GLPI, $GLPI_CACHE; include(GLPI_ROOT . "/inc/based_config.php"); From 92a45befa37b8cba9af4e7780238c7b4999ff675 Mon Sep 17 00:00:00 2001 From: Rom1-B Date: Mon, 5 Aug 2024 16:21:28 +0200 Subject: [PATCH 05/20] CI --- tests/autoload.php | 134 -------------------------------------------- tests/bootstrap.php | 40 +++++++++++++ 2 files changed, 40 insertions(+), 134 deletions(-) delete mode 100644 tests/autoload.php create mode 100644 tests/bootstrap.php diff --git a/tests/autoload.php b/tests/autoload.php deleted file mode 100644 index 4b5b46c..0000000 --- a/tests/autoload.php +++ /dev/null @@ -1,134 +0,0 @@ -. - * ------------------------------------------------------------------------- - * @copyright Copyright (C) 2015-2023 by Escalade plugin team. - * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html - * @link https://github.com/pluginsGLPI/escalade - * ------------------------------------------------------------------------- - */ - -use Glpi\Cache\CacheManager; -use Glpi\Cache\SimpleCache; -use Symfony\Component\Cache\Adapter\ArrayAdapter; - -ini_set('display_errors', 'On'); -error_reporting(E_ALL); - -define('GLPI_ROOT', __DIR__ . '/../../../'); -define('GLPI_CONFIG_DIR', __DIR__ . '/../../../tests/config'); -define('GLPI_VAR_DIR', __DIR__ . '/files'); -define('GLPI_URI', (getenv('GLPI_URI') ?: 'http://localhost:8088')); -define('GLPI_LOG_DIR', GLPI_VAR_DIR . '/_log'); -define( - 'PLUGINS_DIRECTORIES', - [ - GLPI_ROOT . '/plugins', - GLPI_ROOT . '/tests/fixtures/plugins', - ] -); - -define('TU_USER', '_test_user'); -define('TU_PASS', 'PhpUnit_4'); - -/** - * @var array $CFG_GLPI - * @var \Psr\SimpleCache\CacheInterface $GLPI_CACHE - */ -global $CFG_GLPI, $GLPI_CACHE; - -include(GLPI_ROOT . "/inc/based_config.php"); - -if (!file_exists(GLPI_CONFIG_DIR . '/config_db.php')) { - die("\nConfiguration file for tests not found\n\nrun: bin/console glpi:database:install --config-dir=tests/config ...\n\n"); -} - -// Create subdirectories of GLPI_VAR_DIR based on defined constants -foreach (get_defined_constants() as $constant_name => $constant_value) { - if ( - preg_match('/^GLPI_[\w]+_DIR$/', $constant_name) - && preg_match('/^' . preg_quote(GLPI_VAR_DIR, '/') . '\//', $constant_value) - ) { - is_dir($constant_value) or mkdir($constant_value, 0755, true); - } -} - -//init cache -if (file_exists(GLPI_CONFIG_DIR . DIRECTORY_SEPARATOR . CacheManager::CONFIG_FILENAME)) { - // Use configured cache for cache tests - $cache_manager = new CacheManager(); - $GLPI_CACHE = $cache_manager->getCoreCacheInstance(); -} else { - // Use "in-memory" cache for other tests - $GLPI_CACHE = new SimpleCache(new ArrayAdapter()); -} - -global $PLUGIN_HOOKS; - -include_once GLPI_ROOT . 'inc/includes.php'; -include_once GLPI_ROOT . '/plugins/escalade/vendor/autoload.php'; -include_once GLPI_ROOT . '/plugins/escalade/setup.php'; -include_once GLPI_ROOT . '/plugins/escalade/hook.php'; - -$auth = new Auth(); -$user = new User(); -$auth->auth_succeded = true; -$user->getFromDB(2); -$auth->user = $user; -Session::init($auth); -Session::initEntityProfiles(2); -Session::changeProfile(4); -plugin_escalade_install(); -plugin_init_escalade(); -$plugins = new Plugin(); -if (!$plugins->getFromDBbyDir('escalade')) { - $plugins->add([ - 'directory' => 'escalade', - 'name' => 'escalade', - 'version' => PLUGIN_ESCALADE_VERSION, - 'state' => Plugin::ACTIVATED, - ]); -} - -if (!file_exists(GLPI_LOG_DIR . '/php-errors.log')) { - file_put_contents(GLPI_LOG_DIR . '/php-errors.log', ''); -} - -if (!file_exists(GLPI_LOG_DIR . '/sql-errors.log')) { - file_put_contents(GLPI_LOG_DIR . '/sql-errors.log', ''); -} - -// @codingStandardsIgnoreStart -class GlpitestPHPerror extends \Exception -{ -} -class GlpitestPHPwarning extends \Exception -{ -} -class GlpitestPHPnotice extends \Exception -{ -} -class GlpitestSQLError extends \Exception -{ -} -// @codingStandardsIgnoreEnd diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..084b371 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,40 @@ +. + * ------------------------------------------------------------------------------- + * @copyright Copyright (C) 2022-2023 by Teclib'. + * @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html + * @link https://services.glpi-network.com + * ------------------------------------------------------------------------------- + */ + +global $CFG_GLPI, $PLUGIN_HOOKS; + +define('GLPI_ROOT', __DIR__ . '/../../../'); +define('GLPI_LOG_DIR', __DIR__ . '/files/_logs'); + +define('TU_USER', 'glpi'); +define('TU_PASS', 'glpi'); +define('GLPI_LOG_LVL', 'DEBUG'); + +require GLPI_ROOT . '/inc/includes.php'; From 66f16188ca710e55e96538f97250f62ea1bc176a Mon Sep 17 00:00:00 2001 From: Rom1-B Date: Mon, 5 Aug 2024 16:21:28 +0200 Subject: [PATCH 06/20] CI --- tests/autoload.php | 134 -------------------------------------------- tests/bootstrap.php | 40 +++++++++++++ 2 files changed, 40 insertions(+), 134 deletions(-) delete mode 100644 tests/autoload.php create mode 100644 tests/bootstrap.php diff --git a/tests/autoload.php b/tests/autoload.php deleted file mode 100644 index 4b5b46c..0000000 --- a/tests/autoload.php +++ /dev/null @@ -1,134 +0,0 @@ -. - * ------------------------------------------------------------------------- - * @copyright Copyright (C) 2015-2023 by Escalade plugin team. - * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html - * @link https://github.com/pluginsGLPI/escalade - * ------------------------------------------------------------------------- - */ - -use Glpi\Cache\CacheManager; -use Glpi\Cache\SimpleCache; -use Symfony\Component\Cache\Adapter\ArrayAdapter; - -ini_set('display_errors', 'On'); -error_reporting(E_ALL); - -define('GLPI_ROOT', __DIR__ . '/../../../'); -define('GLPI_CONFIG_DIR', __DIR__ . '/../../../tests/config'); -define('GLPI_VAR_DIR', __DIR__ . '/files'); -define('GLPI_URI', (getenv('GLPI_URI') ?: 'http://localhost:8088')); -define('GLPI_LOG_DIR', GLPI_VAR_DIR . '/_log'); -define( - 'PLUGINS_DIRECTORIES', - [ - GLPI_ROOT . '/plugins', - GLPI_ROOT . '/tests/fixtures/plugins', - ] -); - -define('TU_USER', '_test_user'); -define('TU_PASS', 'PhpUnit_4'); - -/** - * @var array $CFG_GLPI - * @var \Psr\SimpleCache\CacheInterface $GLPI_CACHE - */ -global $CFG_GLPI, $GLPI_CACHE; - -include(GLPI_ROOT . "/inc/based_config.php"); - -if (!file_exists(GLPI_CONFIG_DIR . '/config_db.php')) { - die("\nConfiguration file for tests not found\n\nrun: bin/console glpi:database:install --config-dir=tests/config ...\n\n"); -} - -// Create subdirectories of GLPI_VAR_DIR based on defined constants -foreach (get_defined_constants() as $constant_name => $constant_value) { - if ( - preg_match('/^GLPI_[\w]+_DIR$/', $constant_name) - && preg_match('/^' . preg_quote(GLPI_VAR_DIR, '/') . '\//', $constant_value) - ) { - is_dir($constant_value) or mkdir($constant_value, 0755, true); - } -} - -//init cache -if (file_exists(GLPI_CONFIG_DIR . DIRECTORY_SEPARATOR . CacheManager::CONFIG_FILENAME)) { - // Use configured cache for cache tests - $cache_manager = new CacheManager(); - $GLPI_CACHE = $cache_manager->getCoreCacheInstance(); -} else { - // Use "in-memory" cache for other tests - $GLPI_CACHE = new SimpleCache(new ArrayAdapter()); -} - -global $PLUGIN_HOOKS; - -include_once GLPI_ROOT . 'inc/includes.php'; -include_once GLPI_ROOT . '/plugins/escalade/vendor/autoload.php'; -include_once GLPI_ROOT . '/plugins/escalade/setup.php'; -include_once GLPI_ROOT . '/plugins/escalade/hook.php'; - -$auth = new Auth(); -$user = new User(); -$auth->auth_succeded = true; -$user->getFromDB(2); -$auth->user = $user; -Session::init($auth); -Session::initEntityProfiles(2); -Session::changeProfile(4); -plugin_escalade_install(); -plugin_init_escalade(); -$plugins = new Plugin(); -if (!$plugins->getFromDBbyDir('escalade')) { - $plugins->add([ - 'directory' => 'escalade', - 'name' => 'escalade', - 'version' => PLUGIN_ESCALADE_VERSION, - 'state' => Plugin::ACTIVATED, - ]); -} - -if (!file_exists(GLPI_LOG_DIR . '/php-errors.log')) { - file_put_contents(GLPI_LOG_DIR . '/php-errors.log', ''); -} - -if (!file_exists(GLPI_LOG_DIR . '/sql-errors.log')) { - file_put_contents(GLPI_LOG_DIR . '/sql-errors.log', ''); -} - -// @codingStandardsIgnoreStart -class GlpitestPHPerror extends \Exception -{ -} -class GlpitestPHPwarning extends \Exception -{ -} -class GlpitestPHPnotice extends \Exception -{ -} -class GlpitestSQLError extends \Exception -{ -} -// @codingStandardsIgnoreEnd diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..a5b1177 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,40 @@ +. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2015-2023 by Escalade plugin team. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/escalade + * ------------------------------------------------------------------------- + */ + +global $CFG_GLPI, $PLUGIN_HOOKS; + +define('GLPI_ROOT', __DIR__ . '/../../../'); +define('GLPI_LOG_DIR', __DIR__ . '/files/_logs'); + +define('TU_USER', 'glpi'); +define('TU_PASS', 'glpi'); +define('GLPI_LOG_LVL', 'DEBUG'); + +require GLPI_ROOT . '/inc/includes.php'; From 6f00830103994083c25a4492f411579b3ec4f5cb Mon Sep 17 00:00:00 2001 From: Rom1-B Date: Mon, 5 Aug 2024 16:28:45 +0200 Subject: [PATCH 07/20] fix filename --- phpunit.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml b/phpunit.xml index 2d75f57..0e64e40 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,4 +1,4 @@ - + tests/units From 26d7db438333c2c6782ffece97cfc07044791ae6 Mon Sep 17 00:00:00 2001 From: Rom1-B Date: Mon, 5 Aug 2024 16:38:00 +0200 Subject: [PATCH 08/20] fix filename --- phpunit.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 0e64e40..3023d8c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,7 +1,7 @@ - - tests/units + + tests From 0fc451d4f16b4d80fce0b15aabbc8d8d85ed42a4 Mon Sep 17 00:00:00 2001 From: Rom1-B Date: Mon, 5 Aug 2024 16:43:21 +0200 Subject: [PATCH 09/20] fix filename --- tests/units/{TaskMessage.php => TaskMessageTest.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename tests/units/{TaskMessage.php => TaskMessageTest.php} (99%) diff --git a/tests/units/TaskMessage.php b/tests/units/TaskMessageTest.php similarity index 99% rename from tests/units/TaskMessage.php rename to tests/units/TaskMessageTest.php index ad57bf5..a03d3f8 100644 --- a/tests/units/TaskMessage.php +++ b/tests/units/TaskMessageTest.php @@ -30,7 +30,7 @@ use PHPUnit\Framework\TestCase; -class TaskMessage extends TestCase +class TaskMessageTest extends TestCase { protected function dataTestEscalationTaskGroup(): array { From db2c37e041f9df1fc0e5c6ad72b8b91fbb829ba0 Mon Sep 17 00:00:00 2001 From: Lainow Date: Tue, 6 Aug 2024 11:33:34 +0200 Subject: [PATCH 10/20] Fix units test --- composer.json | 5 ++++ inc/ticket.class.php | 17 ----------- tests/EscaladeTestCase.php | 46 +++++++++++++++++++++++++++++ tests/units/TaskMessageTest.php | 51 ++++++++++++++++++++++----------- 4 files changed, 86 insertions(+), 33 deletions(-) create mode 100644 tests/EscaladeTestCase.php diff --git a/composer.json b/composer.json index ba0cd71..7fdd0a4 100644 --- a/composer.json +++ b/composer.json @@ -20,5 +20,10 @@ "allow-plugins": { "phpstan/extension-installer": true } + }, + "autoload": { + "psr-4": { + "GlpiPlugin\\Escalade\\Tests\\": "tests" + } } } diff --git a/inc/ticket.class.php b/inc/ticket.class.php index 88c016d..da4a4b5 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -75,23 +75,6 @@ function ($carry, $type) use ($item) { $old_groups = array_filter($ticket_actors['assign'], function ($actor) { return isset($actor['itemtype']) && $actor['itemtype'] === 'Group'; }); - - // Get deletion rights for each type of actor - $deletion_rights = [ - User::getType() => [ - 'requester' => $config['remove_delete_requester_user_btn'], - 'observer' => $config['remove_delete_watcher_user_btn'], - 'assign' => $config['remove_delete_assign_user_btn'], - ], - Group::getType() => [ - 'requester' => $config['remove_delete_requester_group_btn'], - 'observer' => $config['remove_delete_watcher_group_btn'], - 'assign' => $config['remove_delete_assign_group_btn'], - ], - Supplier::getType() => [ - 'assign' => $config['remove_delete_assign_supplier_btn'], - ], - ]; } if (!isset($item->input['actortype'])) { $groups = new Group_Ticket(); diff --git a/tests/EscaladeTestCase.php b/tests/EscaladeTestCase.php new file mode 100644 index 0000000..bd77133 --- /dev/null +++ b/tests/EscaladeTestCase.php @@ -0,0 +1,46 @@ +beginTransaction(); + parent::setUp(); + } + + protected function tearDown(): void + { + global $DB; + $DB->rollback(); + parent::tearDown(); + } + + protected function login( + string $user_name = TU_USER, + string $user_pass = TU_PASS, + bool $noauto = true, + bool $expected = true + ): Auth { + Session::destroy(); + Session::start(); + + $auth = new Auth(); + $this->assertEquals($expected, $auth->login($user_name, $user_pass, $noauto)); + + return $auth; + } + + protected function logOut() + { + $ctime = $_SESSION['glpi_currenttime']; + Session::destroy(); + $_SESSION['glpi_currenttime'] = $ctime; + } +} diff --git a/tests/units/TaskMessageTest.php b/tests/units/TaskMessageTest.php index a03d3f8..1b98f52 100644 --- a/tests/units/TaskMessageTest.php +++ b/tests/units/TaskMessageTest.php @@ -28,15 +28,32 @@ * ------------------------------------------------------------------------- */ -use PHPUnit\Framework\TestCase; +namespace GlpiPlugin\Scim\Tests\Units; -class TaskMessageTest extends TestCase +use GlpiPlugin\Escalade\Tests\EscaladeTestCase; +use Group; +use Group_Ticket; +use Plugin; +use PluginEscaladeConfig; +use Ticket; +use TicketTask; + +final class TaskMessageTest extends EscaladeTestCase { + public function testPluginReactivated() + { + $this->login(); + PluginEscaladeConfig::loadInSession(); + $_SESSION['glpilanguage'] = 'en_GB'; + $plugins = new Plugin(); + $plugins->getFromDBbyDir('escalade'); + $this->assertTrue(Plugin::isPluginActive('escalade')); + } protected function dataTestEscalationTaskGroup(): array { $ticket = new Ticket(); $ticket->add([ - 'name' => 'Test', + 'name' => 'Escalation Test', 'content' => '', ]); @@ -53,26 +70,25 @@ protected function dataTestEscalationTaskGroup(): array return [ [ 'expected' => [ - 'groups_count' => 0, - 'tasks_count' => 0, - 'last_task_content' => null, + 'group_name' => null, 'ticket_id' => $ticket->getID(), 'group_id' => null, ], 'inputs' => [ 'id' => $ticket->getID(), + 'name' => 'Escalation Test 1', + 'update' => true, ], ], [ 'expected' => [ - 'groups_count' => 1, - 'tasks_count' => 1, - 'last_task_content' => 'Escalation to the group Test Group.', + 'group_name' => $group_test->getName(), 'ticket_id' => $ticket->getID(), 'group_id' => $group_test->getID(), ], 'inputs' => [ 'id' => $ticket->getID(), + 'name' => 'Escalation Test 2', '_actors' => [ 'assign' => [ [ @@ -81,18 +97,18 @@ protected function dataTestEscalationTaskGroup(): array ], ], ], + 'update' => true, ], ], [ 'expected' => [ - 'groups_count' => 1, - 'tasks_count' => 2, - 'last_task_content' => 'Escalation to the group Test Group 2.', + 'group_name' => $group_test_2->getName(), 'ticket_id' => $ticket->getID(), 'group_id' => $group_test_2->getID(), ], 'inputs' => [ 'id' => $ticket->getID(), + 'name' => 'Escalation Test 3', '_actors' => [ 'assign' => [ [ @@ -105,6 +121,7 @@ protected function dataTestEscalationTaskGroup(): array ], ], ], + 'update' => true, ], ], ]; @@ -116,18 +133,20 @@ protected function dataTestEscalationTaskGroup(): array public function testEscalationTaskGroup($expected, $inputs) { $ticket = new Ticket(); - $ticket->update($inputs); + $ticket->getFromDB($expected['ticket_id']); + + $this->assertTrue($ticket->update($inputs)); $ticket_group = new Group_Ticket(); $t_groups = $ticket_group->find(['tickets_id' => $expected['ticket_id']]); - $this->assertEquals(count($t_groups), $expected['groups_count']); + $t_groups = end($t_groups); + $this->assertEquals($t_groups['groups_id'] ?? null, $expected['group_id']); $ticket_task = new TicketTask(); $t_tasks = $ticket_task->find(['tickets_id' => $expected['ticket_id']]); - $this->assertEquals(count($t_tasks), $expected['tasks_count']); $last_task = end($t_tasks); if ($last_task) { - $this->assertEquals($last_task['content'], $expected['last_task_content']); + $this->assertStringContainsString($expected['group_name'], $last_task['content']); } } } From 44483f1425206f99ada150800ed233d28a97d6ec Mon Sep 17 00:00:00 2001 From: Lainow Date: Tue, 6 Aug 2024 11:45:21 +0200 Subject: [PATCH 11/20] Fix header --- tests/EscaladeTestCase.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/EscaladeTestCase.php b/tests/EscaladeTestCase.php index bd77133..3fd8b2b 100644 --- a/tests/EscaladeTestCase.php +++ b/tests/EscaladeTestCase.php @@ -1,5 +1,33 @@ . + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2015-2023 by Escalade plugin team. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/escalade + * ------------------------------------------------------------------------- + */ + namespace GlpiPlugin\Escalade\Tests; use Auth; From 0fdc45ede691ff21158220f79cb68c14151af73a Mon Sep 17 00:00:00 2001 From: Lainow Date: Tue, 6 Aug 2024 12:22:38 +0200 Subject: [PATCH 12/20] Fix lint --- tests/units/TaskMessageTest.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/units/TaskMessageTest.php b/tests/units/TaskMessageTest.php index 1b98f52..fc43b01 100644 --- a/tests/units/TaskMessageTest.php +++ b/tests/units/TaskMessageTest.php @@ -31,11 +31,9 @@ namespace GlpiPlugin\Scim\Tests\Units; use GlpiPlugin\Escalade\Tests\EscaladeTestCase; -use Group; use Group_Ticket; use Plugin; use PluginEscaladeConfig; -use Ticket; use TicketTask; final class TaskMessageTest extends EscaladeTestCase @@ -51,18 +49,18 @@ public function testPluginReactivated() } protected function dataTestEscalationTaskGroup(): array { - $ticket = new Ticket(); + $ticket = new \Ticket(); $ticket->add([ 'name' => 'Escalation Test', 'content' => '', ]); - $group_test = new Group(); + $group_test = new \Group(); $group_test->add([ 'name' => 'Test Group', ]); - $group_test_2 = new Group(); + $group_test_2 = new \Group(); $group_test_2->add([ 'name' => 'Test Group 2', ]); @@ -132,7 +130,7 @@ protected function dataTestEscalationTaskGroup(): array */ public function testEscalationTaskGroup($expected, $inputs) { - $ticket = new Ticket(); + $ticket = new \Ticket(); $ticket->getFromDB($expected['ticket_id']); $this->assertTrue($ticket->update($inputs)); From de44d164170ff66c655fba65bb24f8097b2c0b3c Mon Sep 17 00:00:00 2001 From: "Romain B." <8530352+Rom1-B@users.noreply.github.com> Date: Tue, 6 Aug 2024 12:34:31 +0200 Subject: [PATCH 13/20] Update tests/units/TaskMessageTest.php --- tests/units/TaskMessageTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/units/TaskMessageTest.php b/tests/units/TaskMessageTest.php index fc43b01..c212d92 100644 --- a/tests/units/TaskMessageTest.php +++ b/tests/units/TaskMessageTest.php @@ -28,7 +28,7 @@ * ------------------------------------------------------------------------- */ -namespace GlpiPlugin\Scim\Tests\Units; +namespace GlpiPlugin\Escalade\Tests\Units; use GlpiPlugin\Escalade\Tests\EscaladeTestCase; use Group_Ticket; From 9f3c04ca8ae43ed11095903a93af78426d54a618 Mon Sep 17 00:00:00 2001 From: Lainow Date: Tue, 6 Aug 2024 13:59:50 +0200 Subject: [PATCH 14/20] Update units tests --- inc/ticket.class.php | 2 +- tests/units/TaskMessageTest.php | 160 ++++++++++++++++++++++++++------ 2 files changed, 132 insertions(+), 30 deletions(-) diff --git a/inc/ticket.class.php b/inc/ticket.class.php index da4a4b5..06344be 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -573,7 +573,7 @@ public static function removeAssignUsers($item, $keep_users_id = false, $type = return true; } - $tickets_id = $item->input['id']; + $tickets_id = $item->input['id'] ?? $item->fields['id']; $where_keep = [ 'tickets_id' => $tickets_id, diff --git a/tests/units/TaskMessageTest.php b/tests/units/TaskMessageTest.php index c212d92..faaff48 100644 --- a/tests/units/TaskMessageTest.php +++ b/tests/units/TaskMessageTest.php @@ -34,6 +34,7 @@ use Group_Ticket; use Plugin; use PluginEscaladeConfig; +use Ticket_User; use TicketTask; final class TaskMessageTest extends EscaladeTestCase @@ -49,22 +50,6 @@ public function testPluginReactivated() } protected function dataTestEscalationTaskGroup(): array { - $ticket = new \Ticket(); - $ticket->add([ - 'name' => 'Escalation Test', - 'content' => '', - ]); - - $group_test = new \Group(); - $group_test->add([ - 'name' => 'Test Group', - ]); - - $group_test_2 = new \Group(); - $group_test_2->add([ - 'name' => 'Test Group 2', - ]); - return [ [ 'expected' => [ @@ -125,26 +110,143 @@ protected function dataTestEscalationTaskGroup(): array ]; } - /** - * @dataProvider dataTestEscalationTaskGroup - */ - public function testEscalationTaskGroup($expected, $inputs) + public function testGroupEscalation() { $ticket = new \Ticket(); - $ticket->getFromDB($expected['ticket_id']); + $ticket->add([ + 'name' => 'Escalation Test', + 'content' => '', + ]); + + $user_test = new \User(); + $user_test->add([ + 'name' => 'Escalation Technician', + ]); + + $group_test = new \Group(); + $group_test->add([ + 'name' => 'Escalation Group', + ]); + + // Update ticket with a technician + $this->assertTrue($ticket->update( + [ + 'id' => $ticket->getID(), + '_actors' => [ + 'assign' => [ + [ + 'items_id' => $user_test->getID(), + 'itemtype' => $user_test->getType() + ], + ], + ], + ] + )); + + // Check that the group linked to this ticket is "Test group 1" and that the technician has disappeared. + $ticket_user = new Ticket_User(); + $ticket_user->getFromDBByCrit(['tickets_id' => $ticket->getID()]); + $this->assertEquals($ticket_user->fields['users_id'], $user_test->getID()); + + // Update ticket with a group + $this->assertTrue($ticket->update( + [ + 'id' => $ticket->getID(), + '_actors' => [ + 'assign' => [ + [ + 'items_id' => $user_test->getID(), + 'itemtype' => $user_test->getType() + ], + [ + 'items_id' => $group_test->getID(), + 'itemtype' => 'Group' + ] + ], + ], + ] + )); - $this->assertTrue($ticket->update($inputs)); + // Check that the group linked to this ticket is "Test group 1" and that the technician has disappeared. + $ticket_user = new Ticket_User(); + $t_users = $ticket_user->find(['tickets_id' => $ticket->getID()]); + $this->assertEquals(count($t_users), 0); + // Check that the group linked to this ticket is "Test group 1" and that the technician has disappeared. $ticket_group = new Group_Ticket(); - $t_groups = $ticket_group->find(['tickets_id' => $expected['ticket_id']]); - $t_groups = end($t_groups); - $this->assertEquals($t_groups['groups_id'] ?? null, $expected['group_id']); + $ticket_group->getFromDBByCrit(['tickets_id' => $ticket->getID()]); + $this->assertEquals($ticket_group->fields['groups_id'], $group_test->getID()); + } + + public function testTaskGroupEscalation() + { + $ticket = new \Ticket(); + $ticket->add([ + 'name' => 'Task Group Escalation Test', + 'content' => '', + ]); + + $group_test = new \Group(); + $group_test->add([ + 'name' => 'Task Group 1', + ]); + + $group_test_2 = new \Group(); + $group_test_2->add([ + 'name' => 'Task Group 2', + ]); + // Update ticket with just one group + $this->assertTrue($ticket->update( + [ + 'id' => $ticket->getID(), + '_actors' => [ + 'assign' => [ + [ + 'items_id' => $group_test->getID(), + 'itemtype' => 'Group' + ], + ], + ], + ] + )); + + // Check the correct task content $ticket_task = new TicketTask(); - $t_tasks = $ticket_task->find(['tickets_id' => $expected['ticket_id']]); + $t_tasks = $ticket_task->find(['tickets_id' => $ticket->getID()]); $last_task = end($t_tasks); - if ($last_task) { - $this->assertStringContainsString($expected['group_name'], $last_task['content']); - } + $this->assertStringContainsString('Task Group 1', $last_task['content']); + + $this->assertTrue($ticket->update( + [ + 'id' => $ticket->getID(), + '_actors' => [ + 'assign' => [ + [ + 'items_id' => $group_test->getID(), + 'itemtype' => 'Group' + ], + [ + 'items_id' => $group_test_2->getID(), + 'itemtype' => 'Group' + ], + ], + ], + ] + )); + + // Check the correct order of tasks and content + $ticket_task = new TicketTask(); + $t_tasks = $ticket_task->find(['tickets_id' => $ticket->getID()]); + $first_task = reset($t_tasks); + $this->assertStringContainsString('Task Group 1', $first_task['content']); + $last_task = end($t_tasks); + $this->assertStringContainsString('Task Group 2', $last_task['content']); + + // Check that the group linked to this ticket is "Test group 2". + $ticket_group = new Group_Ticket(); + $t_groups = $ticket_group->find(['tickets_id' => $ticket->getID()]); + $t_groups = end($t_groups); + $this->assertEquals($t_groups['groups_id'], $group_test_2->getID()); } } From 7f6d94ff3daa84c30fed9958c3040606f59c63e4 Mon Sep 17 00:00:00 2001 From: Lainow Date: Tue, 6 Aug 2024 14:24:01 +0200 Subject: [PATCH 15/20] Remove useless dataprovider --- tests/units/TaskMessageTest.php | 61 --------------------------------- 1 file changed, 61 deletions(-) diff --git a/tests/units/TaskMessageTest.php b/tests/units/TaskMessageTest.php index faaff48..f32f4b4 100644 --- a/tests/units/TaskMessageTest.php +++ b/tests/units/TaskMessageTest.php @@ -48,67 +48,6 @@ public function testPluginReactivated() $plugins->getFromDBbyDir('escalade'); $this->assertTrue(Plugin::isPluginActive('escalade')); } - protected function dataTestEscalationTaskGroup(): array - { - return [ - [ - 'expected' => [ - 'group_name' => null, - 'ticket_id' => $ticket->getID(), - 'group_id' => null, - ], - 'inputs' => [ - 'id' => $ticket->getID(), - 'name' => 'Escalation Test 1', - 'update' => true, - ], - ], - [ - 'expected' => [ - 'group_name' => $group_test->getName(), - 'ticket_id' => $ticket->getID(), - 'group_id' => $group_test->getID(), - ], - 'inputs' => [ - 'id' => $ticket->getID(), - 'name' => 'Escalation Test 2', - '_actors' => [ - 'assign' => [ - [ - 'items_id' => $group_test->getID(), - 'itemtype' => 'Group' - ], - ], - ], - 'update' => true, - ], - ], - [ - 'expected' => [ - 'group_name' => $group_test_2->getName(), - 'ticket_id' => $ticket->getID(), - 'group_id' => $group_test_2->getID(), - ], - 'inputs' => [ - 'id' => $ticket->getID(), - 'name' => 'Escalation Test 3', - '_actors' => [ - 'assign' => [ - [ - 'items_id' => $group_test->getID(), - 'itemtype' => 'Group' - ], - [ - 'items_id' => $group_test_2->getID(), - 'itemtype' => 'Group' - ], - ], - ], - 'update' => true, - ], - ], - ]; - } public function testGroupEscalation() { From 6632d38b196e0799119c9bd1dd1126fb52de15b5 Mon Sep 17 00:00:00 2001 From: LAUNAY Samuel <107540223+Lainow@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:18:45 +0200 Subject: [PATCH 16/20] Update tests/bootstrap.php Co-authored-by: Adrien Clairembault <42734840+AdrienClairembault@users.noreply.github.com> --- tests/bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index a5b1177..e231a5b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -28,7 +28,7 @@ * ------------------------------------------------------------------------- */ -global $CFG_GLPI, $PLUGIN_HOOKS; +global $CFG_GLPI; define('GLPI_ROOT', __DIR__ . '/../../../'); define('GLPI_LOG_DIR', __DIR__ . '/files/_logs'); From becdf4648fa84a025592ac27b94c2d4978436cb5 Mon Sep 17 00:00:00 2001 From: Lainow Date: Tue, 6 Aug 2024 15:22:22 +0200 Subject: [PATCH 17/20] Add suggestions --- tests/bootstrap.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index e231a5b..7f788c6 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -28,10 +28,10 @@ * ------------------------------------------------------------------------- */ -global $CFG_GLPI; +global $CFG_GLPI, $PLUGIN_HOOKS; define('GLPI_ROOT', __DIR__ . '/../../../'); -define('GLPI_LOG_DIR', __DIR__ . '/files/_logs'); +define('GLPI_LOG_DIR', GLPI_ROOT . '/files/_logs'); define('TU_USER', 'glpi'); define('TU_PASS', 'glpi'); From 79602ce642b78eeba0f85120964caf151b475b47 Mon Sep 17 00:00:00 2001 From: "Romain B." <8530352+Rom1-B@users.noreply.github.com> Date: Wed, 7 Aug 2024 08:40:30 +0200 Subject: [PATCH 18/20] try --- tests/bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 7f788c6..5b3f1e7 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -30,7 +30,7 @@ global $CFG_GLPI, $PLUGIN_HOOKS; -define('GLPI_ROOT', __DIR__ . '/../../../'); +define('GLPI_ROOT', dirname(__DIR__, 3)); define('GLPI_LOG_DIR', GLPI_ROOT . '/files/_logs'); define('TU_USER', 'glpi'); From 89cdebc191a7b242e31fb8cc8a37b0241427d397 Mon Sep 17 00:00:00 2001 From: Lainow Date: Wed, 28 Aug 2024 11:06:57 +0200 Subject: [PATCH 19/20] Update CHANGELOG.md --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a67a863..74f69dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [unrelease] - +### Fixed + +- Correction of the task message generated during escalation + +### Added + +- Configuring transiflex as a CI + ## [2.9.8] - 2024-07-15 ### Fixed From e3fc7460d7d587fc9eb6d059d03cd702f1973b4b Mon Sep 17 00:00:00 2001 From: Lainow Date: Wed, 28 Aug 2024 12:20:12 +0200 Subject: [PATCH 20/20] Update CHANGELOG.md --- CHANGELOG.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74f69dc..53fffad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,10 +11,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Correction of the task message generated during escalation -### Added - -- Configuring transiflex as a CI - ## [2.9.8] - 2024-07-15 ### Fixed