【发布时间】:2014-02-09 09:18:04
【问题描述】:
我正在尝试模拟这种方法:
$transformer = $this->transformerFactory->createProductTransformer($product, function (ProductInterface $product) use ($discount) {
$product->setDiscount($discount);
});
它接受回调参数作为第二个参数,我不知道如何模拟它。
我正在使用 Mockery,所以它看起来像这样:
$this->transformerFactoryMock
->shouldReceive('createProductTransformer')
->with(???) // here!
如果我将相同的回调传递给 with() 方法,则实例不匹配。 如果 Mockery 不支持,我不介意使用 PHPUnit 模拟。
【问题讨论】:
标签: php unit-testing mocking phpunit mockery