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.06k stars 313 forks source link

Architecture expectations passing when they are expected to fail. #1148

Open ghowardPI opened 2 months ago

ghowardPI commented 2 months ago

What Happened

Expect('App\Enums')->toBeEnums(); is passing although my App doesn't contain an Enums directory. The test is executed in tests/Unit/ArchTest.php

pest Pest2

How to Reproduce

I set up a fresh Laravel app and ran test('app')->expect('App\Enums')->toBeEnums(); inside tests/Unit/ArchTest.php, which passes. However the app does not contain the App\Enums directory.

Sample Repository

No response

Pest Version

2.34

PHP Version

8.2.6

Operation System

Windows

Notes

No response

Katalam commented 2 months ago

This is not a bug. If there is no directory, there are no classes/files, but at the same time all found classes/files are enums, so in theoretical terms the statement is correct. All files in App\Enums are Enums

avenjamin commented 1 month ago

@ghowardPI I ran into this as well but when I read the docs the parameter you pass to the expect() function is NOT a file path - it's a namespace.

So you can stick a file with namespace App\Enums into say the App\Models folder and it'll still be processed by your test.