How can I get PHPUnit MockObjects to return different values based on a parameter?

前端 未结 11 1635
忘掉有多难
忘掉有多难 2020-12-04 05:43

I\'ve got a PHPUnit mock object that returns \'return value\' no matter what its arguments:

// From inside a test...
$mock = $this->getMock(\         


        
11条回答
  •  广开言路
    2020-12-04 06:28

    Do you mean something like this?

    public function TestSomeCondition($condition){
      $mockObj = $this->getMockObject();
      $mockObj->setReturnValue('yourMethod',$condition);
    }
    

提交回复
热议问题