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

[5.2] Adding a method to disable model observers in tests. #13178

Merged
merged 3 commits into from
Apr 18, 2016

Conversation

joshforbes
Copy link
Contributor

I often find myself having to disable model observers in my tests. As this method functions very similarly to withoutEvents or withoutJobs it seemed like it would be a natural fit for the framework. The expected usage would be:

$this->withoutObservers(JobObserver::class);

or

$this->withoutObservers([JobObserver::class, PostObserver::class]);

* These observers will be mocked, so that they will not actually be executed.
*
* @param array|string $observers
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing returj annotation

@GrahamCampbell GrahamCampbell changed the title Adding a method to disable model observers in tests. [5.2] Adding a method to disable model observers in tests. Apr 16, 2016
@taylorotwell taylorotwell merged commit 49ddac6 into laravel:5.2 Apr 18, 2016
@joshforbes joshforbes deleted the disable-observer branch April 18, 2016 23:54
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

Successfully merging this pull request may close these issues.

3 participants