示例#1
0
 /**
  * @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());
 }
示例#3
0
文件: Bill.php 项目: jrdnhannah/billr
 /**
  * @return Money
  */
 public function getAmountDue()
 {
     return Money::fromInteger($this->amount);
 }
示例#4
0
 /**
  * @return Money
  */
 public function getRecurringCharge()
 {
     return Money::fromInteger((int) $this->recurringCharge);
 }