/** * @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_persist_an_account_to_the_database() { $repository = new AccountRepository(); $command = $this->configureOpenAccountCommand(); $account = Account::open($command->getService(), $command->getAccountNumber(), $command->getRecurringCharge(), $command->getDateOpened(), $command->getBillingPeriod()); $handler = new OpenAccountCommandHandler($this->getEventDispatcherMock(), $repository); $handler->handle($command); $this->assertSame(1, count($repository->findAll())); $this->assertEquals($account, $repository->findAll()[0]); }
/** * @param OpenAccountCommand $command * @return void */ public function handle($command) { $account = Account::open($command->getService(), $command->getAccountNumber(), $command->getRecurringCharge(), $command->getDateOpened(), $command->getBillingPeriod()); $this->accountRepository->save($account); $this->dispatch('account.opened', new AccountWasOpenedEvent($account)); }
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()); }
/** * {@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')); }