From 674dfebb0d2f291ef8c96eeb5b0211c509fb9552 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Wed, 23 Oct 2024 15:46:44 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B07803=20:white=5Fcheck=5Fmark:=20Skip=20t?= =?UTF-8?q?est=20if=20itop-hub-connector=20is=20not=20installed=20(new=20h?= =?UTF-8?q?elper=20to=20handle=20this=20in=20any=20other=20tests)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../itop-hub-connector/AjaxPageTest.php | 7 +++++++ .../src/BaseTestCase/ItopDataTestCase.php | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/tests/php-unit-tests/integration-tests/itop-hub-connector/AjaxPageTest.php b/tests/php-unit-tests/integration-tests/itop-hub-connector/AjaxPageTest.php index 3e54cc0af..f9d8af0d2 100644 --- a/tests/php-unit-tests/integration-tests/itop-hub-connector/AjaxPageTest.php +++ b/tests/php-unit-tests/integration-tests/itop-hub-connector/AjaxPageTest.php @@ -3,12 +3,19 @@ namespace Combodo\iTop\Test\UnitTest\HubConnector; use Combodo\iTop\Application\Helper\Session; use Combodo\iTop\Test\UnitTest\ItopDataTestCase; +use PHPUnit\Framework\SkippedTestCase; class AjaxPageTest extends ItopDataTestCase { const USE_TRANSACTION = false; const AUTHENTICATION_TOKEN = '14b5da9d092f84044187421419a0347e7317bc8cd2b486fdda631be06b959269'; const AUTHENTICATION_PASSWORD = "tagada-Secret,007"; + protected function setUp(): void + { + $this->SkipIfModuleNotPresent('itop-hub-connector'); + parent::setUp(); + } + public function testCompileOperation() { // Given diff --git a/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php b/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php index 3d5aba722..cde0f101a 100644 --- a/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php +++ b/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php @@ -1392,4 +1392,18 @@ abstract class ItopDataTestCase extends ItopTestCase ]); return $sLogin; } + + /** + * Can be invoked in setUp or any test method to skip the test if the module is not present + * + * @param string $sModule e.g: itop-hub-connector + * + * @return void + */ + protected function SkipIfModuleNotPresent(string $sModule): void + { + if (!file_exists(\utils::GetAbsoluteModulePath($sModule))) { + self::markTestSkipped("Test skipped: module '$sModule' is not present"); + } + } }