作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
\Phake::captureAll 返回连续调用中使用的参数数组。它对于标量或者传递不同的对象时工作得很好,但当使用相同的对象时就不是很有用。 data mapper 经常发生这种情况当 CUT 多次修改并保留对象时,会进行模拟。
在下面的示例中,我尝试断言第一个 $mock->fooWithArgument
是使用预期参数调用的,但找不到这样做的方法:
public function testArgumentCapturingAllValls()
{
$mock = \Phake::mock('PhakeTest_MockedClass');
$obj1 = new \stdClass;
$obj1->bar = 1;
$mock->fooWithArgument($obj1);
$obj1->bar = 2;
$mock->fooWithArgument($obj1);
\Phake::verify($mock, \Phake::atLeast(1))->fooWithArgument(\Phake::captureAll($toArgument));
$this->assertEquals(1, $toArgument[0]->bar); //fails, as both elements point to the same instance
}
最佳答案
使用 v2.x 框架是不可能的。 The corresponding PR正在考虑中, future 的版本可能支持此类用例。
关于php - Phake框架: how to clone objects on captureAll?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38566796/
\Phake::captureAll 返回连续调用中使用的参数数组。它对于标量或者传递不同的对象时工作得很好,但当使用相同的对象时就不是很有用。 data mapper 经常发生这种情况当 CUT 多
我是一名优秀的程序员,十分优秀!