【发布时间】:2014-09-26 09:02:49
【问题描述】:
我正在使用 Mockery 来定义一个期望,即我的 mock 上的函数应该以对象作为参数调用。我在我的测试中声明了预期的对象。问题是测试中的对象与我的代码中的对象通过引用不是同一个对象 - 有没有办法断言两个对象的相等性而不是确切的引用?
测试片段
$resource = new Resource("Test");
$this->aThing
->shouldReceive('call')
->with($resource)
->andReturn(true)
->once();
代码片段
public function respondWithString()
{
// assume $this->aThing is the injected mock
$resource = new Resource("Test");
$response = $this->aThing->call($resource);
return $response;
}
【问题讨论】:
标签: unit-testing tdd phpunit mockery