diff --git a/tests/php-unit-tests/ItopTestCase.php b/tests/php-unit-tests/ItopTestCase.php
index 18c6c6a68..afc7c8a28 100644
--- a/tests/php-unit-tests/ItopTestCase.php
+++ b/tests/php-unit-tests/ItopTestCase.php
@@ -39,14 +39,16 @@ class ItopTestCase extends TestCase
/** @noinspection UsingInclusionOnceReturnValueInspection avoid errors for approot includes */
protected function setUp(): void
{
- @include_once '../approot.inc.php';
- @include_once '../../approot.inc.php';
- @include_once '../../../approot.inc.php';
- @include_once '../../../../approot.inc.php';
- @include_once '../../../../../approot.inc.php';
- @include_once '../../../../../../approot.inc.php';
- @include_once '../../../../../../../approot.inc.php';
- @include_once '../../../../../../../../approot.inc.php';
+ $sAppRootRelPath = 'approot.inc.php';
+ $sDepthSeparator = '../';
+ for ($iDepth = 0; $iDepth < 8; $iDepth++) {
+ if (file_exists($sAppRootRelPath)) {
+ require_once $sAppRootRelPath;
+ break;
+ }
+
+ $sAppRootRelPath = $sDepthSeparator.$sAppRootRelPath;
+ }
}
/**
diff --git a/tests/php-unit-tests/phpunit.xml.dist b/tests/php-unit-tests/phpunit.xml.dist
index 099fb9406..b1cc926bf 100644
--- a/tests/php-unit-tests/phpunit.xml.dist
+++ b/tests/php-unit-tests/phpunit.xml.dist
@@ -65,16 +65,16 @@
- ../../../env-production/*/test
+ ../../env-production/*/test
- ../../../core/apc-emulation.php
- ../../../core/ormlinkset.class.inc.php
- ../../../datamodels/2.x/itop-tickets/main.itop-tickets.php
+ ../../core/apc-emulation.php
+ ../../core/ormlinkset.class.inc.php
+ ../../datamodels/2.x/itop-tickets/main.itop-tickets.php
diff --git a/tests/php-unit-tests/unitary-tests/core/WeeklyScheduledProcessTest.php b/tests/php-unit-tests/unitary-tests/core/WeeklyScheduledProcessTest.php
index a8cef1666..031a016c1 100644
--- a/tests/php-unit-tests/unitary-tests/core/WeeklyScheduledProcessTest.php
+++ b/tests/php-unit-tests/unitary-tests/core/WeeklyScheduledProcessTest.php
@@ -11,7 +11,7 @@ class WeeklyScheduledProcessTest extends ItopTestCase
{
parent::setUp();
require_once(APPROOT.'core/backgroundprocess.inc.php');
- require_once(APPROOT.'tests/core/WeeklyScheduledProcessMockConfig.php');
+ require_once(APPROOT.'tests/php-unit-tests/unitary-tests/core/WeeklyScheduledProcessMockConfig.php');
}
diff --git a/tests/php-unit-tests/unitary-tests/core/sanitizer/HTMLDOMSanitizerTest.php b/tests/php-unit-tests/unitary-tests/core/sanitizer/HTMLDOMSanitizerTest.php
index f5448e701..76c30434a 100644
--- a/tests/php-unit-tests/unitary-tests/core/sanitizer/HTMLDOMSanitizerTest.php
+++ b/tests/php-unit-tests/unitary-tests/core/sanitizer/HTMLDOMSanitizerTest.php
@@ -222,7 +222,7 @@ class HTMLDOMSanitizerTest extends AbstractDOMSanitizerTest
*/
public function testDoSanitizeCallInlineImageProcessImageTag($sHtml, $iExpectedCount)
{
- require_once APPROOT.'tests/core/sanitizer/InlineImageMock.php';
+ require_once APPROOT.'tests/php-unit-tests/unitary-tests/core/sanitizer/InlineImageMock.php';
InlineImageMock::ResetCallCounter();
$oSanitizer = new HTMLDOMSanitizer(InlineImageMock::class);
diff --git a/tests/php-unit-tests/unitary-tests/datamodels/2.x/authent-local/UserLocalTest.php b/tests/php-unit-tests/unitary-tests/datamodels/2.x/authent-local/UserLocalTest.php
index 12a1c34f4..867a28ed5 100644
--- a/tests/php-unit-tests/unitary-tests/datamodels/2.x/authent-local/UserLocalTest.php
+++ b/tests/php-unit-tests/unitary-tests/datamodels/2.x/authent-local/UserLocalTest.php
@@ -25,7 +25,7 @@ class UserLocalTest extends ItopDataTestCase
{
parent::setUp();
- require_once(APPROOT.'tests/php-unit-tests/tests/datamodels/2.x/authent-local/UserLocalTest/UserLocalPasswordPolicyMock.php');
+ require_once(APPROOT.'tests/php-unit-tests/unitary-tests/datamodels/2.x/authent-local/UserLocalTest/UserLocalPasswordPolicyMock.php');
require_once(APPROOT.'env-production/authent-local/model.authent-local.php');
}
diff --git a/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/Validator/iTopConfigAstValidatorTest.php b/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/Validator/iTopConfigAstValidatorTest.php
index c29d285d6..68eb076e1 100644
--- a/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/Validator/iTopConfigAstValidatorTest.php
+++ b/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/Validator/iTopConfigAstValidatorTest.php
@@ -19,8 +19,8 @@ class iTopConfigAstValidatorTest extends ItopTestCase
{
parent::setUp();
- require_once __DIR__.'/../../../env-production/itop-config/src/Validator/ConfigNodesVisitor.php';
- require_once __DIR__.'/../../../env-production/itop-config/src/Validator/iTopConfigAstValidator.php';
+ require_once APPROOT.'env-production/itop-config/src/Validator/ConfigNodesVisitor.php';
+ require_once APPROOT.'env-production/itop-config/src/Validator/iTopConfigAstValidator.php';
}
diff --git a/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/Validator/iTopConfigSyntaxValidatorTest.php b/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/Validator/iTopConfigSyntaxValidatorTest.php
index 77427cd94..c4a5aaa1e 100644
--- a/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/Validator/iTopConfigSyntaxValidatorTest.php
+++ b/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/Validator/iTopConfigSyntaxValidatorTest.php
@@ -20,8 +20,8 @@ class iTopConfigSyntaxValidatorTest extends ItopTestCase
{
parent::setUp();
- require_once __DIR__.'/../../../env-production/itop-config/src/Validator/ConfigNodesVisitor.php';
- require_once __DIR__.'/../../../env-production/itop-config/src/Validator/iTopConfigSyntaxValidator.php';
+ require_once APPROOT.'env-production/itop-config/src/Validator/ConfigNodesVisitor.php';
+ require_once APPROOT.'env-production/itop-config/src/Validator/iTopConfigSyntaxValidator.php';
}
diff --git a/tests/php-unit-tests/unitary-tests/status/StatusIncTest.php b/tests/php-unit-tests/unitary-tests/status/StatusIncTest.php
index 645c9ded5..a135e13de 100644
--- a/tests/php-unit-tests/unitary-tests/status/StatusIncTest.php
+++ b/tests/php-unit-tests/unitary-tests/status/StatusIncTest.php
@@ -38,7 +38,7 @@ class StatusIncTest extends TestCase {
{
//AppRoot is the directory containing the directory
//Assume getcwd() is runned inside APPROOT/test
- $this->sAppRoot = __DIR__.'/../../sources/application/status';
+ $this->sAppRoot = __DIR__.'/../../../../sources/application/status';
}
/**
diff --git a/tests/php-unit-tests/unitary-tests/status/status.php b/tests/php-unit-tests/unitary-tests/status/status.php
index c81b17aff..3c89ef55e 100644
--- a/tests/php-unit-tests/unitary-tests/status/status.php
+++ b/tests/php-unit-tests/unitary-tests/status/status.php
@@ -1,8 +1,10 @@