From 22467d05c818874a5984cc5dcbbdd99901bc9783 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Wed, 22 Mar 2023 11:24:21 +0100 Subject: [PATCH] fix underscores in test names --- src/Support/Str.php | 2 ++ tests/Unit/Support/Str.php | 2 +- tests/Unit/TestName.php | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Support/Str.php b/src/Support/Str.php index 21ee5c5b..ee4e7231 100644 --- a/src/Support/Str.php +++ b/src/Support/Str.php @@ -59,6 +59,8 @@ final class Str */ public static function evaluable(string $code): string { + $code = str_replace('_', '__', $code); + $code = self::PREFIX.str_replace(' ', '_', $code); // sticks to PHP8.2 function naming rules https://www.php.net/manual/en/functions.user-defined.php diff --git a/tests/Unit/Support/Str.php b/tests/Unit/Support/Str.php index 57fa9006..4d865c86 100644 --- a/tests/Unit/Support/Str.php +++ b/tests/Unit/Support/Str.php @@ -8,6 +8,6 @@ it('evaluates the code', function ($evaluatable, $expected) { expect($code)->toBe($expected); })->with([ ['version()', '__pest_evaluable_version__'], - ['version__ ', '__pest_evaluable_version___'], + ['version__ ', '__pest_evaluable_version_____'], ['version\\', '__pest_evaluable_version_'], ]); diff --git a/tests/Unit/TestName.php b/tests/Unit/TestName.php index b7f91d54..0f0fecfe 100644 --- a/tests/Unit/TestName.php +++ b/tests/Unit/TestName.php @@ -13,6 +13,8 @@ it('may start with P', function (string $real, string $toBePrinted) { ]); $names = [ + 'test description' => '__pest_evaluable_test_description', + 'test_description' => '__pest_evaluable_test__description', 'ふ+が+' => '__pest_evaluable_ふ_が_', 'ほげ' => '__pest_evaluable_ほげ', '卜竹弓一十山' => '__pest_evaluable_卜竹弓一十山',