From 48ae4bfc18fa15d50e9f4499c11e4d2ab4448cf1 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 21 Mar 2023 13:43:01 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20description=20when=20using=20`=E3=81=B5?= =?UTF-8?q?=E3=81=8C`=20chars?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Support/Str.php | 2 +- tests/Unit/TestName.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Support/Str.php b/src/Support/Str.php index 9ed75c1f..896710c3 100644 --- a/src/Support/Str.php +++ b/src/Support/Str.php @@ -61,7 +61,7 @@ final class Str { $code = self::PREFIX.str_replace(' ', '_', $code); - return (string) preg_replace('/[^A-Z_a-z0-9]/', '_', $code); + return (string) preg_replace('/[^\p{L}_0-9]/', '_', $code); } /** diff --git a/tests/Unit/TestName.php b/tests/Unit/TestName.php index 3f52e700..2d5ce4aa 100644 --- a/tests/Unit/TestName.php +++ b/tests/Unit/TestName.php @@ -11,3 +11,23 @@ it('may start with P', function (string $real, string $toBePrinted) { ['PPPackages\Foo', 'PPPackages\Foo'], ['PPPackages\Foo', 'PPPackages\Foo'], ]); + +$names = [ + 'ふが' => '__pest_evaluable_ふが', + 'ほげ' => 'ほげ', + '卜竹弓一十山' => '卜竹弓一十山', + '!p8VrB' => '!p8VrB', + '&xe6VeKWF#n4' => '&xe6VeKWF#n4', + '%%HurHUnw7zM!' => '%%HurHUnw7zM!', + 'rundeliekend' => 'rundeliekend', + 'g%%c!Jt9$fy#Kf' => 'g%%c!Jt9$fy#Kf', + 'NRs*Gz2@hmB$W$BPD%%b2U%3P%z%apnwSX' => 'NRs*Gz2@hmB$W$BPD%%b2U%3P%z%apnwSX', +]; + +foreach ($names as $name => $methodName) { + test($name) + ->expect(fn () => static::getLatestPrintableTestCaseMethodName()) + ->toBe($name) + ->and(fn () => $this->name()) + ->toBe($methodName); +}