open() public method

public open ( ) : Dumplie\SharedKernel\Application\Transaction\Transaction
return Dumplie\SharedKernel\Application\Transaction\Transaction
 /**
  * @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;
     }
 }
 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]);
 }
示例#3
0
 /**
  * @param Command $command
  * @param ServiceLocator $serviceLocator
  */
 public function pre(Command $command, ServiceLocator $serviceLocator)
 {
     $this->transaction = $this->factory->open();
 }