mocking - PHPUnit mock with multiple expects() calls -


using phpunit, wonder how can have multiple expectation same stub/mock.

for example, want test mock have method display() called , return null. want test method process() called.

in fact test called testprocessiscalledifdisplayreturnnull().

so need setup 2 expectations on same mock object, , manual doesn't :(

if know, method called once use $this->once() in expects(), otherwise use $this->any()

$mock = $this->getmock('nameofthecalss', array('firstmethod','secondmethod','thirdmethod')); $mock->expects($this->once())      ->method('firstmethod')      ->will($this->returnvalue('value')); $mock->expects($this->once())      ->method('secondmethod')      ->will($this->returnvalue('value')); $mock->expects($this->once())      ->method('thirdmethod')      ->will($this->returnvalue('value')); 

Comments

Popular posts from this blog

Python __call__ special method practical example -

How can I edit my VIM config so that Vim treats ".ejs" files the same as it currently treats my html files? -