0
$observer = $this->getMockBuilder('Apps_Sample_DataHandler')
->disableOriginalConstructor()
->disableOriginalClone()
->disableArgumentCloning()
->getMock();
$observer->method('getSampleData')
->will($this->returnCallback('mockTestCall'));
$this->assertEquals('foo', $observer->getSampleData());
ここでは、 'getSampleData'メソッドを 'mockTestCall'でモックしようとしています。PHPユニットテスト:メソッドをモックしながら複数のパラメータを渡すにはどうしたらいいですか?
「mockTestCall」メソッドにパラメータを渡す方法を知りたかったのです。メソッド 'mockTestCall' の
定義は以下の通りである:
public function mockTestCall($arg1){
return $arg1;
}