N°7803 Skip test if itop-hub-connector is not installed (new helper to handle this in any other tests)

This commit is contained in:
Romain Quetiez
2024-10-23 15:46:44 +02:00
parent 764eddd9f8
commit 674dfebb0d
2 changed files with 21 additions and 0 deletions

View File

@@ -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

View File

@@ -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");
}
}
}