function it_can_sum(Money $money1, Money $money2, Money $money3) { $currency = new Currency('USD'); $money1->getAmount()->willReturn(1); $money1->getCurrency()->willReturn($currency); $money2->getAmount()->willReturn(2); $money2->getCurrency()->willReturn($currency); $money3->getAmount()->willReturn(3); $money3->getCurrency()->willReturn($currency); $this->sum(array($money1, $money2, $money3))->shouldBeLike(new Money(6, $currency)); }
/** * $money / $fraction * * @param Money $money * @param float|integer $fraction * @return Money */ public function divide(Money $money, $fraction) { return new Money($money->getAmount() / $fraction, $money->getCurrency()); }