From 3af4114a1b62e5fc46f8862a5e7051d51b06684c Mon Sep 17 00:00:00 2001 From: Sergey Kleyman Date: Mon, 13 Jan 2025 14:05:31 +0200 Subject: [PATCH] Fixed StackTraceUtilTest --- tests/ElasticApmTests/Util/AssertMessageStack.php | 2 +- tests/ElasticApmTests/Util/StackTraceFrameExpectations.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/ElasticApmTests/Util/AssertMessageStack.php b/tests/ElasticApmTests/Util/AssertMessageStack.php index 56883efa3..66a1ca56d 100644 --- a/tests/ElasticApmTests/Util/AssertMessageStack.php +++ b/tests/ElasticApmTests/Util/AssertMessageStack.php @@ -39,7 +39,7 @@ final class AssertMessageStack implements LoggableInterface { /** @var bool */ - private static $isEnabled = true; + private static $isEnabled = false; /** @var ?AssertMessageStack */ private static $singleton = null; diff --git a/tests/ElasticApmTests/Util/StackTraceFrameExpectations.php b/tests/ElasticApmTests/Util/StackTraceFrameExpectations.php index 284f3fedf..2f46b5182 100644 --- a/tests/ElasticApmTests/Util/StackTraceFrameExpectations.php +++ b/tests/ElasticApmTests/Util/StackTraceFrameExpectations.php @@ -122,10 +122,11 @@ public static function fromClosure(string $fileName, int $lineNumber, ?string $n if (PHP_VERSION_ID < 80400) { $result = self::fromClassMethodUnknownLocation($class, $isStatic, ($namespace === null ? '' : ($namespace . '\\')) . '{closure}'); } else { - $result = self::fromClassMethodUnknownLocation($class, $isStatic, '{closure:' . $class . '::__METHOD__():__LINE__}'); + $result = self::fromClassMethodUnknownLocation($class, $isStatic, '{closure:__CLASS__::__METHOD__():__LINE__}'); $expectedFunc = $result->function->getValue(); TestCaseBase::assertNotNull($expectedFunc); $expectedFuncRegex = self::convertFunctionNameToRegPattern($expectedFunc); + $expectedFuncRegex = str_replace('__CLASS__', '[a-zA-Z0-9\\\\]+', $expectedFuncRegex); $expectedFuncRegex = str_replace('__METHOD__', '[a-zA-Z0-9]+', $expectedFuncRegex); $expectedFuncRegex = str_replace('__LINE__', '[0-9]+', $expectedFuncRegex); $result->function->setValue($expectedFuncRegex);