【发布时间】:2014-01-28 00:18:27
【问题描述】:
我正在尝试使用带有标量值的 let 函数。 我的问题是价格是双倍的,我希望是整数 5。
function let(Buyable $buyable, $price, $discount)
{
$buyable->getPrice()->willReturn($price);
$this->beConstructedWith($buyable, $discount);
}
function it_returns_the_same_price_if_discount_is_zero($price = 5, $discount = 0) {
$this->getDiscountPrice()->shouldReturn(5);
}
错误:
✘ it returns the same price if discount is zero
expected [integer:5], but got [obj:Double\stdClass\P14]
有没有办法使用 let 函数注入 5?
【问题讨论】:
标签: php unit-testing phpspec