2014-10-22 20 views
7

Aynı işleve, ancak farklı argümanlara sahip iki çağrı alan bir nesneye benzemeye çalışıyorum. Birden çok çağrı için farklı geri dönüş değerleri vermek oldukça basittir, ancak argüman doğrulama ile nasıl yapılacağını hiçbir yerde bulamıyorum.Birden çok çağrı için beklenen argümanları belirleyen mockery

$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'); 

Ve

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

Ama onlar işi :

denedim.

Çıktıdan PHPUnit bana bir dizi alıyorum gibi görünüyor? hızlıydı

cevap

10

Eh P Anlaşılan bunu yapabilirsiniz ve sadece iyi çalışır:

$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'); 
İlgili konular