Mockery defining expected arguments for multiple calls

I am trying to make fun of an object that receives two calls of the same function, but with different arguments. It's pretty straightforward to return different return values ​​for multiple calls, but I can't find anywhere else to do this with argument checking.

I tried:

$this->eventDispatcher ->shouldReceive('dispatch') ->twice() ->with(Events::SELECT,\Mockery::type('\Not\Really\A\Namespace\Event')) ->with(Events::ACTIVITY,\Mockery::type('\Not\Really\A\Namespace\Event'); 

and

 $this->eventDispatcher ->shouldReceive('dispatch') ->twice() ->with( [Events::SELECT,\Mockery::type('\Not\Really\A\Namespace\Event')], [Events::ACTIVITY,\Mockery::type('\Not\Really\A\Namespace\Event')] ); 

But they do not work .

From the output of PHPUnit it seems to me that I'm getting an array?

+7
php symfony mocking phpunit mockery
source share
1 answer

Well, that was fast; P Obviously, you can do this, and it works just fine:

 $this->eventDispatcher ->shouldReceive('dispatch') ->with(Events::SELECT,\Mockery::type('\Not\Really\A\Namespace\Event')); $this->eventDispatcher ->shouldReceive('dispatch') ->with(Events::ACTIVITY,\Mockery::type('\Not\Really\A\Namespace\Event'); 
+10
source share

All Articles