-
Notifications
You must be signed in to change notification settings - Fork 279
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Pest generated tests #726
Fix Pest generated tests #726
Conversation
Thanks. Is this ready, or a WIP? |
You're welcome @jasonmccreary! Yes, this is ready. |
Merged this before taking that close of a look. Two things I'm curious about:
|
Thanks!
...or to the base test case, but I was unsure if it would be acceptable to modify files outside those generated by Blueprint. Let me know if you'd like me to take that approach! |
Thanks. Fair point. Blueprint does modify the routes files. So doing so for Pest, especially if it streamlines code, should be ok. Assuming this is still how Pest does it - common config in a base Pest file? |
Sounds good! Tomorrow, I'll give it a go. In the meantime, here's a small PR to fix a test related to this feature: #729 |
@jasonmccreary, here's the PR to Import AdditionalAssertions to base test case when generating Pest tests: #733 |
On a clean installation, the generated Pest tests fail because
assertActionUsesFormRequest
is an undefined method.Steps to replicate
Installation:
Initialize Blueprint:
Comment out PHPUnit and uncomment Pest:
Create draft:
Generate:
Run tests:
Tests fail with the following error:
Reason
This happens for two reasons:
PestTestGenerator
is not callingaddTrait
to addAdditionalAssertions
.PestTestGenerator
uses the traitHandlesTraits
, but Pest tests manage traits differently:pest()->use()
.Solution
Tests relying on
assertActionUsesFormRequest
should include the following:This PR achieves that outcome by adding this logic when processing a
ValidateStatement
:The
PestTestGenerator
now uses its ownaddTrait
method instead of relying onHandlesTraits
. Given that this method is specific toPestTestGenerator
and not shared across other classes, introducing it locally rather than creating a new concern seemed appropriate.