Пример #1
0
 function it_rethrows_exception_and_rollbacks_transaction_in_catch_exception_command_endpoint(Factory $factory, Transaction $transaction, ServiceLocator $serviceLocator)
 {
     $command = new CreateCart((string) CartId::generate(), "PLN");
     $factory->open()->willReturn($transaction);
     $transaction->rollback()->shouldBeCalled();
     $this->pre($command, $serviceLocator);
     $this->shouldThrow(\Exception::class)->during('catchException', [$command, new \Exception(), $serviceLocator]);
 }
 /**
  * @param string $orderId
  */
 public function customerPlacedOrder(string $orderId)
 {
     $transaction = $this->transactionFactory->open();
     try {
         $this->eventLog->log(new CustomerPlacedOrder($orderId));
         $transaction->commit();
     } catch (\Exception $e) {
         $transaction->rollback();
         throw $e;
     }
 }
Пример #3
0
 /**
  * @param Command $command
  * @param ServiceLocator $serviceLocator
  */
 public function pre(Command $command, ServiceLocator $serviceLocator)
 {
     $this->transaction = $this->factory->open();
 }