/** * @test */ public function it_should_only_accept_floats_and_integers() { $money1 = DTO\Money::fromFloat(12.99); $this->assertSame(12.99, $money1->toFloat()); $this->assertSame(1299, $money1->toInt()); $money2 = DTO\Money::fromInteger(1599); $this->assertSame(15.99, $money2->toFloat()); $this->assertSame(1599, $money2->toInt()); }
/** * @test */ public function it_should_pay_a_bill() { $dispatcher = $this->getMockForAbstractClass('\\Symfony\\Component\\EventDispatcher\\EventDispatcherInterface'); $account = $this->getMockBuilder('\\HCLabs\\Bills\\Model\\Account')->disableOriginalConstructor()->getMock(); $charge = Money::fromInteger(2000); $account->expects($this->once())->method('getRecurringCharge')->willReturn($charge); $billRepository = new BillRepository(); $commandHandler = new PayBillCommandHandler($dispatcher, $billRepository); $bill = Bill::create($account, new \DateTime('tomorrow')); $command = new PayBillCommand($bill); $this->assertFalse($bill->hasBeenPaid()); $commandHandler->handle($command); $this->assertTrue($bill->hasBeenPaid()); }
/** * @return Money */ public function getAmountDue() { return Money::fromInteger($this->amount); }
/** * @return Money */ public function getRecurringCharge() { return Money::fromInteger((int) $this->recurringCharge); }