From f66ce1c9569ff25cbb6fc6206cdea2690e38f895 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Tue, 7 Apr 2026 19:06:30 +0200 Subject: [PATCH] :white_check_mark: Fix cURL calls to iTop within Docker dev. environment with PHP version autodetection (#869) --- tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php | 10 ++++++++++ 1 file changed, 10 insertions(+) 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); } }