df1[which(df1$a %in% df2$a)[1:nrow(df2)],] <- df2
> df1
a b
1 0 0
2 0 0
3 0 0
4 0 0
5 1 1
6 1 1
7 1 0
8 2 0
9 2 0
我们正在尝试模拟方法&#39; getSampleData&#39;与&#39; mockTestCall&#39;。
我们想知道如何将参数传递给方法&#39; mockTestCall&#39;。
方法的定义&#39; mockTestCall&#39;如下:
$observer = $this->getMockBuilder('Apps_Sample_DataHandler')
->disableOriginalConstructor()
->disableOriginalClone()
->disableArgumentCloning()
->getMock();
$observer->method('getSampleData')
->will($this->returnCallback('mockTestCall'));
$this->assertEquals('foo', $observer->getSampleData());
答案 0 :(得分:0)
对于PHP&gt; = 5.4:
$that = $this;
$observer->method('getSampleData')
->will($this->returnCallback(
function() use($that) {
$that->mockTestCall('arg1_value');
}
));
对于PHP 5.3:
{{1}}