Skip to content
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

Multiple uses statements influence working of test suite #30

Closed
Joucke opened this issue May 25, 2020 · 2 comments
Closed

Multiple uses statements influence working of test suite #30

Joucke opened this issue May 25, 2020 · 2 comments

Comments

@Joucke
Copy link

Joucke commented May 25, 2020

I added a new line in my Pest.php, below uses(TestCase::class)->in('Feature');:
uses(RefreshDatabase::class)->in('Feature');

Like suggested in https://pestphp.com/docs/underlying-test-case/

After some debugging, with no functionality from TestCase::class, I figured out I had to combine these, or else the latter will override the former, leaving TestCase functionality out of my tests.

This gave me errors like

InvalidArgumentException
Unable to locate factory for [App\Category].

and

Error
Call to undefined method Tests\Feature\AddingStatementsToCategoriesTest::get()

when trying to use pestphp on Laravel 7.

I fixed it all this way:

uses(TestCase::class, RefreshDatabase::class)->in('Feature');

Maybe the documentation could be clearer about this, or I'm just stupid for trying ;-).

@alexmartinfr
Copy link
Collaborator

alexmartinfr commented May 25, 2020

You are not stupid :)
Indeed I think we could improve the doc clarity on that point.

You can submit a revised version of the documentation page, just click the "Edit this page" link on the top right 🙂

If you prefer, you can also open an issue with your edit suggestion on the Pest website repo: https://github.com/pestphp/website and I'll be happy to edit/publish it into the doc.

Thanks!

@alexmartinfr
Copy link
Collaborator

The documentation should now be clearer about the correct usage of uses() : Underlying Test Case.

@fetzi fetzi closed this as completed Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants