Exemplo n.º 1
0
 /**
  * Test if order completed triggers an event.
  */
 public function testOrderCompletedTriggersAnEvent()
 {
     $event_triggered = false;
     $this->dispatcher->listen(DispatcherInterface::ON_ORDER_COMPLETED, function (GatewayInterface $gateway, OrderInterface $order) use(&$event_triggered) {
         $this->assertInstanceOf(ExampleOffsiteGateway::class, $gateway);
         $this->assertInstanceOf(OrderInterface::class, $order);
         $this->assertEquals($this->order->getReference(), $order->getReference());
         $event_triggered = true;
     });
     $this->gateway->triggerOrderCompleted($this->order);
     $this->assertTrue($event_triggered);
 }
 /**
  * Trigger order has been partially refunded.
  *
  * @param OrderInterface              $order
  * @param OrderItemInterface[]        $items
  * @param DateTimeValueInterface|null $timestamp
  */
 public function triggerOrderPartiallyRefunded(OrderInterface $order, array $items = null, DateTimeValueInterface $timestamp = null)
 {
     $this->orders[$order->getReference()] = $order;
     if (empty($timestamp)) {
         $timestamp = new DateTimeValue();
     }
     $refund = new Refund($order->getReference() . '-X', $order->getReference(), $timestamp, 200);
     $refund->setGateway($this);
     if (!empty($items)) {
         $refund->setItems($items);
     }
     $this->refunds[$refund->getReference()] = $refund;
     $this->getDispatcher()->triggerOrderPartiallyRefunded($this, $order, $refund);
 }