/** * @param $billingDetails * @return Billing\AbstractBill * @throws Exception\BillingMethodNotSupported */ public function start($billingDetails) { $client = $this->clientRepository->findOneClientById($billingDetails['clientId']); $bill = $this->billingManager->bill($client, $billingDetails['charges']); $this->eventDispatcher->dispatch("billed_client", new ClientBilledEvent($client, $bill)); return $bill; }
public function it_bills_the_client_and_dispatches_an_event(ClientRepository $clientRepository, BillingManager $billingManager, EventDispatcherInterface $eventDispatcher, Client $client, AbstractBill $bill) { $clientRepository->findOneClientById(123)->shouldBeCalled()->willReturn($client); $billingManager->bill($client, 'someCharges')->shouldBeCalled()->willReturn($bill); $eventDispatcher->dispatch("billed_client", Argument::type(ClientBilledEvent::class))->shouldBeCalled(); $this->start(array('clientId' => 123, 'charges' => 'someCharges'))->shouldBe($bill); }