Fix issue where order of CLI arguments matters#334
Open
matthewswain wants to merge 1 commit into
Open
Conversation
The TestCommand uses ignoreValidationErrors to allow it to accept and pass through arbitrary options to phpunit/paratest. For example it does not define `--stop-on-error` but can pass it through to phpunit. A side effect of this is that the order of options matters, e.g. `php artisan test -p --recreate-databases --stop-on-error` does recreate databases, while `php artisan test -p --stop-on-error --recreate-databases` does not. This appears to be because when the validator hits an option it does not know about, it stops processing and any subsequent options cannot be resolved via $this->option. It looks like this was previously handled when passing through options to phpunit/paratest but was not handled when setting environment variables, this change fixes that.
iBotPeaches
approved these changes
Jan 2, 2026
iBotPeaches
left a comment
There was a problem hiding this comment.
No idea if this fixes it, but I just spent a chunk of time painfully wondering why this was occurring. Trying to find TestCommand in Laravel to learn it was part of Collision, to then this PR.
Thanks for fix - hope it gets merged.
|
I also found this issue today and wondered why it wasn't working, then found my way here. I manually applied this PR to my dev environment (still using Laravel v10.48.29 and nunomaduro/collision v7.11.0) but it did allow my command to run. Before this PR: After this PR: This anecdote doesn't prove this PR works for all other options combinations, but appears solved for the above scenario with Paratest. |
|
Same issue here, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi @nunomaduro ,
Thanks for maintaining this project! Hopefully I have explained my change in enough detail below but please let me know if it needs further explanation or changes.
The TestCommand uses ignoreValidationErrors to allow it to accept and pass through arbitrary options to phpunit/paratest. For example it does not define
--stop-on-errorbut can pass it through to phpunit.A side effect of this is that the order of options matters, e.g.
php artisan test -p --recreate-databases --stop-on-errordoes recreate databases, whilephp artisan test -p --stop-on-error --recreate-databasesdoes not.This appears to be because when the validator hits an option it does not know about, it stops processing and any subsequent options cannot be resolved via $this->option.
It looks like this was previously handled when passing through options to phpunit/paratest but was not handled when setting environment variables, this change fixes that.