/** * @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; }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(['display_label' => 'Money', 'empty_data' => function (FormInterface $form) { return Money::fromFloat((double) $form->get('money')->getData()); }]); }
private function getAccount() { return Account::open(Service::fromName(new ProvidedService('foo')), new AccountNumber('abc123'), Money::fromFloat(50.0), new \DateTime('now'), new BillingPeriod('P2Y')); }
/** * @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())); }
/** * {@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(); }
/** * @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')); }
/** * @test */ public function it_should_provide_a_string() { $money = DTO\Money::fromFloat(12.99); $this->assertSame('12.99', (string) $money); }