Answer the question
In order to leave comments, you need to log in
PHPUnit. Mock objects. Stub for another class method?
Situation:
Yii project, PHPUnit tests.
Model:
class Class1 {
static function func1(){
if(Class2::funcOfClass2)
.....
}
....
}
class Class1Test extends PHPUnit_Framework_TestCase {
public function testFunc1(){
$this->assertEquals(Class1::func1());
}
$mock = $this->getMock('Class1', array('Class2::funcOfClass2'));
$mock->expects($this->once()->method('Class2::funcOfClass2')->will($this->returnValue(true)));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question