fix: methods name with \

This commit is contained in:
Nuno Maduro
2022-12-04 23:49:58 +00:00
parent 34878bf432
commit c5f6923e5a
3 changed files with 20 additions and 2 deletions

View File

@ -56,7 +56,7 @@ final class Str
{ {
$code = str_replace(' ', '_', $code); $code = str_replace(' ', '_', $code);
return (string) preg_replace('/[^A-Z_a-z0-9\\\\]/', '', $code); return (string) preg_replace('/[^A-Z_a-z0-9]/', '_', $code);
} }
/** /**

View File

@ -858,6 +858,11 @@
✓ it gets file name from closure ✓ it gets file name from closure
✓ it gets property values ✓ it gets property values
PASS Tests\Unit\Support\Str
✓ it evaluates the code with ('version()', 'version__')
✓ it evaluates the code with ('version__ ', 'version___')
✓ it evaluates the code with ('version\', 'version_')
PASS Tests\Unit\TestSuite PASS Tests\Unit\TestSuite
✓ it does not allow to add the same test description twice ✓ it does not allow to add the same test description twice
✓ it alerts users about tests with arguments but no input ✓ it alerts users about tests with arguments but no input
@ -885,4 +890,4 @@
PASS Tests\Visual\Version PASS Tests\Visual\Version
✓ visual snapshot of help command output ✓ visual snapshot of help command output
Tests: 4 incomplete, 2 todos, 18 skipped, 616 passed (1526 assertions) Tests: 4 incomplete, 2 todos, 18 skipped, 619 passed (1529 assertions)

View File

@ -0,0 +1,13 @@
<?php
use Pest\Support\Str;
it('evaluates the code', function ($evaluatable, $expected) {
$code = Str::evaluable($evaluatable);
expect($code)->toBe($expected);
})->with([
['version()', 'version__'],
['version__ ', 'version___'],
['version\\', 'version_'],
]);