- Notifications
You must be signed in to change notification settings - Fork11.7k
[12.x] Add commandFileFinder method and exclude test files from command discovery#58017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[12.x] Add commandFileFinder method and exclude test files from command discovery#58017
Uh oh!
There was an error while loading.Please reload this page.
Conversation
d03f650 intolaravel:12.xUh oh!
There was an error while loading.Please reload this page.
streamingsystems commentedDec 10, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hi All, I upgraded to the latest version (12.42.0) and my "development:test" command is no longer found. When I reverted back to 12.41.1 it worked fine. I am wondering if this new feature is causing the issue? ERROR Command "development:test" is not defined. Did you mean one of these? (my thought would be that this would have been backwards compatible as it took me a while after my upgrade to figure out why my commands were not working) Thanks for all you do. -Rob |
macropay-solutions commentedDec 12, 2025
@streamingsystems see#58106 (comment) for a solution |
This PR introduces a new
commandFileFindermethod to the console Kernel and updates the command discovery logic to exclude test files by default.Changes
commandFileFinder(array $paths)method that returns theFinderinstance used for discovering command filesloadmethod to use$this->commandFileFinder($paths)instead of directly instantiating the Finder*Test.phpare now excluded from command auto-discovery by defaultBenefits to End Users
Fixes PHPUnit ignoring co-located test files - When developers co-locate PHPUnit test files alongside their command classes in the
Commandsfolder, the command discovery mechanism autoloads these test files before PHPUnit runs. This causes PHPUnit to skip them entirely since the classes are already loaded. By excluding*Test.phpfiles from command discovery, tests are properly executed by PHPUnit.Extensibility - Developers can now override
commandFileFinder()in their application's Kernel to customize which files are discovered (e.g., exclude additional patterns, include specific directories, etc.)