我试图模拟一个对象,该对象获得两个相同函数但具有不同参数的调用.为多个调用返回不同的返回值非常简单但我无法在任何地方找到如何使用参数验证来执行此操作.
我试过了:
$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');
和
$this->eventDispatcher ->shouldReceive('dispatch') ->twice() ->with( [Events::SELECT,\Mockery::type('\Not\Really\A\Namespace\Event')],[Events::ACTIVITY,\Mockery::type('\Not\Really\A\Namespace\Event')] );
但它们不起作用.
嗯,这很快; P显然你可以这样做,它工作得很好:
原文链接:https://www.f2er.com/php/135145.html$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');