@@ -145,8 +145,6 @@ class FeatureContext extends BehatVariablesContext {
145145 * in the apiComments suite.
146146 */
147147 private string $ stepLineRef = '' ;
148- private bool $ sendStepLineRef = false ;
149- private bool $ sendStepLineRefHasBeenChecked = false ;
150148
151149 /**
152150 * @var boolean true if TEST_SERVER_FED_URL is defined
@@ -416,17 +414,6 @@ public function isTestingWithLdap(): bool {
416414 return (\getenv ("TEST_WITH_LDAP " ) === "true " );
417415 }
418416
419- /**
420- * @return bool
421- */
422- public function sendScenarioLineReferencesInXRequestId (): ?bool {
423- if ($ this ->sendStepLineRefHasBeenChecked === false ) {
424- $ this ->sendStepLineRef = (\getenv ("SEND_SCENARIO_LINE_REFERENCES " ) === "true " );
425- $ this ->sendStepLineRefHasBeenChecked = true ;
426- }
427- return $ this ->sendStepLineRef ;
428- }
429-
430417 /**
431418 * @return bool
432419 */
@@ -880,7 +867,7 @@ public function getRemoteBaseUrlWithoutScheme(): string {
880867 * @return string
881868 */
882869 public function getStepLineRef (): string {
883- if (!$ this -> sendStepLineRef ) {
870+ if (!HttpRequestHelper:: sendScenarioLineReferencesInXRequestId () ) {
884871 return '' ;
885872 }
886873
@@ -2435,6 +2422,14 @@ public function substituteInLineCodes(
24352422 "getUUIDv4Regex "
24362423 ],
24372424 "parameter " => []
2425+ ],
2426+ [
2427+ "code " => "%request_id_pattern% " ,
2428+ "function " => [
2429+ __NAMESPACE__ . '\TestHelpers\HttpRequestHelper ' ,
2430+ "getXRequestIdRegex "
2431+ ],
2432+ "parameter " => []
24382433 ]
24392434 ];
24402435 if ($ user !== null ) {
@@ -2522,11 +2517,15 @@ public function substituteInLineCodes(
25222517 $ substitution ["function " ],
25232518 $ substitution ["parameter " ]
25242519 );
2525- foreach ($ functions as $ function => $ parameters ) {
2526- $ replacement = \call_user_func_array (
2527- $ function ,
2528- \array_merge ([$ replacement ], $ parameters )
2529- );
2520+
2521+ // do not run functions on regex patterns
2522+ if (!\str_ends_with ($ value , "_pattern% " )) {
2523+ foreach ($ functions as $ function => $ parameters ) {
2524+ $ replacement = \call_user_func_array (
2525+ $ function ,
2526+ \array_merge ([$ replacement ], $ parameters )
2527+ );
2528+ }
25302529 }
25312530 $ value = \str_replace (
25322531 $ substitution ["code " ],
@@ -2644,7 +2643,7 @@ public function before(BeforeScenarioScope $scope): void {
26442643 $ environment ->registerContext ($ this ->spacesContext );
26452644 }
26462645
2647- if ($ this -> sendScenarioLineReferencesInXRequestId ()) {
2646+ if (HttpRequestHelper:: sendScenarioLineReferencesInXRequestId ()) {
26482647 $ this ->scenarioString = $ suiteName . '/ ' . $ featureFileName . ': ' . $ scenarioLine ;
26492648 } else {
26502649 $ this ->scenarioString = '' ;
@@ -2678,7 +2677,7 @@ public function before(BeforeScenarioScope $scope): void {
26782677 * @return void
26792678 */
26802679 public function beforeEachStep (BeforeStepScope $ scope ): void {
2681- if ($ this -> sendScenarioLineReferencesInXRequestId ()) {
2680+ if (HttpRequestHelper:: sendScenarioLineReferencesInXRequestId ()) {
26822681 $ this ->stepLineRef = $ this ->scenarioString . '- ' . $ scope ->getStep ()->getLine ();
26832682 } else {
26842683 $ this ->stepLineRef = '' ;
0 commit comments