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

When testing, Event mock object lacks of listen() method. #15981

Closed
dvlpp opened this issue Oct 18, 2016 · 1 comment
Closed

When testing, Event mock object lacks of listen() method. #15981

dvlpp opened this issue Oct 18, 2016 · 1 comment

Comments

@dvlpp
Copy link

dvlpp commented Oct 18, 2016

  • Laravel Version: 5.3.19
  • PHP Version: 7.0.0
  • Database Driver & Version: N/A

Description:

Since the 5.3.19 update, some of my tests which implies events and artisan calls have errors. This appends because the App\Console\Kernel::commands() method execute the base_path('routes/console.php') file, in which there is an Artisan::command() call by default, which leads us to Illuminate\Foundation\Console\Kernel::command() in which there is (finally) a $this->app['events']->listen() instruction. But when using, in tests, $this->withoutEvents() (from the MockApplicationServices trait), the mock created here lacks of this listen() method.

Adding a $mock->shouldReceive('listen'); instruction in this method solve the issue. But since I am not sure how deep it can go, so I choose to write an issue instead of creating a PR.

Steps To Reproduce:

Write a test with $this->withoutEvents() and an artisan call, leaving the default routes/console.php file content.

@themsaid
Copy link
Member

Opened a PR to fix that: #16012

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