When I do this in my test:
Event::shouldReceive('fire')->once()->withArgs([Mockery::type('Fry\Events\RouteRequested')]);
I get past the above error, but then I get another:
testing.ERROR: exception 'Mockery\Exception\NoMatchingExpectationException' with message 'No matching handler found for Mockery_0_Illuminate_Events_Dispatcher::fire("creating: index", array(0=>'object(Illuminate\View\View)',)). Either the method was unexpected or its arguments matched no expected argument list for this method
Which is coming from another event being fired. My understanding is that the Mock matches the total method signature (including args), so I don't understand why this is happening.
Anyone else?
I have this problem too. When using Event::shouldRecieve('fire')->withArgs(Mockery::any()); I started writing out all events that Event should recieve, which is very time consuming.
But now I do this:
// Mock the Event facade.
Event::shouldReceive('fire')->once()->withArgs(['user.created.superuser', Mockery::any()]);
// Ignore the rest of Event-calls
Event::shouldReceive('fire')->withAnyArgs();
This will fail if the Event doesn't recieve the user.created.superuser call and keep going no matter which handlers it is missing.
I hope it helps you.
Niels.
Did anybody have luck with resolving this? I tried the code below and I get a pass and it should fail.
Event::shouldReceive('fire')
->with('ManifestRecordCreated',['poseId' => 1, 'stateId' => 1, 'manifestId' => 1])
->once();
Event::shouldReceive('fire')->withAnyArgs();
Event::fire(new ManifestRecordCreated(2, 1, 1));
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community