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

WithoutEvents trait fails due to missing withoutEvents() method #46118

Closed
spaceemotion opened this issue Feb 14, 2023 · 3 comments
Closed

WithoutEvents trait fails due to missing withoutEvents() method #46118

spaceemotion opened this issue Feb 14, 2023 · 3 comments

Comments

@spaceemotion
Copy link

spaceemotion commented Feb 14, 2023

  • Laravel Version: 10
  • PHP Version: 8.2.2
  • Database Driver & Version: 8.0.32

Description:

After upgrading to Laravel 10, a test of mine that uses the WithoutEvents trait, started to fail due to a missing withoutEvents method.

Unable to disable events. ApplicationTrait not used.

The now missing method seems to have been included in a deprecated trait in laravel 9:

The upgrade guide also does not mention the WithoutEvents trait being superseded by another.

Is this a dropped feature, or do I have to replace the trait with a method call?

@derekmd
Copy link
Contributor

derekmd commented Feb 14, 2023

$this->withoutEvents() calls should be replaced with Event::fake(), Event::fakeFor(), etc.

The MocksApplicationServices trait has been marked @deprecated since the laravel/framework 8.x. The 10.x upgrade guide does mention its removal but the note doesn't mention withoutEvents by name: https://laravel.com/docs/10.x/upgrade#service-mocking

@korkoshko
Copy link
Contributor

This method contained in the MocksApplicationServices trait , which was deprecated in the 8.x and removed in version 10.x. You just need use Event::fake .

@spaceemotion
Copy link
Author

Ah alright, thanks! I only searched for mention of the WithoutEvents trait.

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