示例#1
0
 /**
  * @return Bill
  */
 public function getBill()
 {
     $service = Service::fromName(new ProvidedService('foo'));
     $account = Account::open($service, new AccountNumber('abc123'), Money::fromFloat(20.0), new \DateTime('now'), new BillingPeriod('P30D'));
     $bill = Bill::create($account, new \DateTime('now'));
     $this->injectId($bill);
     return $bill;
 }
 /**
  * @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
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(['display_label' => 'Money', 'empty_data' => function (FormInterface $form) {
         return Money::fromFloat((double) $form->get('money')->getData());
     }]);
 }
示例#4
0
 private function getAccount()
 {
     return Account::open(Service::fromName(new ProvidedService('foo')), new AccountNumber('abc123'), Money::fromFloat(50.0), new \DateTime('now'), new BillingPeriod('P2Y'));
 }
示例#5
0
文件: Bill.php 项目: jrdnhannah/billr
 /**
  * @return Money
  */
 public function getAmountDue()
 {
     return Money::fromInteger($this->amount);
 }
示例#6
0
 /**
  * @test
  */
 public function it_should_convert_charge_from_float_to_int_and_back()
 {
     $dateOpened = new \DateTime('now');
     $account = Account::open($this->createServicesAndCompany(), new Value\AccountNumber('1234'), Value\Money::fromFloat(50.0), $dateOpened, new Value\BillingPeriod((new Monthly())->getBillingIntervalString()));
     $accountReflection = new \ReflectionClass($account);
     $chargeProperty = $accountReflection->getProperty('recurringCharge');
     $chargeProperty->setAccessible(true);
     $this->assertSame(5000, $chargeProperty->getValue($account));
     $this->assertEquals(Value\Money::fromFloat(50.0), $account->getRecurringCharge());
 }
 /**
  * @return OpenAccountCommand
  */
 private function configureOpenAccountCommand()
 {
     return new OpenAccountCommand(Service::fromName(new ProvidedService('Hammers for Rental')), new AccountNumber('abc123'), Money::fromFloat(25.0), new \DateTime('now'), new BillingPeriod((new Monthly())->getBillingIntervalString()));
 }
示例#8
0
 /**
  * {@inheritdoc}
  */
 function load(ObjectManager $manager)
 {
     $account = Account::open($this->getReference('service_internet'), new AccountNumber('abc123'), Money::fromFloat(27.5), new \DateTime('now'), new BillingPeriod('P1M'));
     $manager->persist($account);
     $manager->flush();
 }
示例#9
0
 /**
  * @return Money
  */
 public function getRecurringCharge()
 {
     return Money::fromInteger((int) $this->recurringCharge);
 }
 /**
  * @return Account
  */
 private function getAccount()
 {
     $service = Service::fromName(new ProvidedService('FooBar'));
     return Account::open($service, new AccountNumber('abc123'), Money::fromFloat(50.0), new \DateTime('now'), new BillingPeriod((new Monthly())->getBillingIntervalString()), null, new \DateTime('now +2 months'));
 }
示例#11
0
 /**
  * @test
  */
 public function it_should_provide_a_string()
 {
     $money = DTO\Money::fromFloat(12.99);
     $this->assertSame('12.99', (string) $money);
 }