我正在尝试将 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?