diff --git a/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php b/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php index 624747f54..65c1d6eda 100644 --- a/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php +++ b/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php @@ -708,6 +708,16 @@ abstract class ItopTestCase extends KernelTestCase { $sUrl = \MetaModel::GetConfig()->Get('app_root_url')."/$sUri"; + // Add PHP version in header to be able to handle Docker dev environments with automatic PHP version detection (instead of hardcoding the PHP version in the app_root_url) + $sPhpVersion = PHP_VERSION; + $aPhpVersionParts = explode('.', $sPhpVersion); + $sPhpVersionHeaderValue = ($aPhpVersionParts[0] ?? '0').($aPhpVersionParts[1] ?? '0'); + $aCurlOptions = $aCurlOptions ?? []; + $aCurlOptions[CURLOPT_HTTPHEADER] = array_merge( + $aCurlOptions[CURLOPT_HTTPHEADER] ?? [], + ['X-PHP-Version: '.$sPhpVersionHeaderValue] + ); + return $this->CallUrl($sUrl, $aPostFields, $aCurlOptions, $bXDebugEnabled); } }