pestphp / pest

Pest is an elegant PHP testing Framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.
https://pestphp.com
MIT License
9.07k stars 315 forks source link

[Bug]: Certain test file names generate invalid test case class names #1087

Open vkwbpo opened 4 months ago

vkwbpo commented 4 months ago

What Happened

Got error message Unable to create test case for test file at...

How to Reproduce

Create any test file which will produce invalid PHP class name, such as 2FATest.php

Sample Repository

No response

Pest Version

2.24.0

PHP Version

8.1.20

Operation System

macOS, Windows, Linux

Notes

This could be handled by prefixing test class names and replacing any other characters that might be present in test file names but are invalid as parts of PHP class name. Prefix could for example be Pest_$i_ so that +Test.php and =Test.php would not produce the same class names.

Namespaces seem to be handled already, for example folder name A+=BC produces namespace P\Tests\Feature\ABC. However, when folders/files +ABC/Test.php and ABC/Test.php both exist, the second file is skipped on complete test suite run.

EDIT: namespaces starting with numbers also do not create valid test case files.

Katalam commented 2 months ago

@devajmeireles Is this something that is already covered in 3.X? Or should I take a look to prevent this with v3?