Example #1
0
 /**
  * Testing payment error
  *
  */
 public function testPaymentSuccess()
 {
     $this->stripeMethod->expects($this->once())->method('getCreditCartNumber')->will($this->returnValue(self::CART_NUMBER));
     $this->stripeMethod->expects($this->once())->method('getCreditCartExpirationMonth')->will($this->returnValue(self::CART_EXPIRE_MONTH));
     $this->stripeMethod->expects($this->once())->method('getCreditCartExpirationYear')->will($this->returnValue(self::CART_EXPIRE_YEAR));
     $this->paymentBridge->expects($this->once())->method('getOrder')->will($this->returnValue(1));
     $this->stripeMethod->expects($this->any())->method('setTransactionId')->with($this->equalTo('123'))->will($this->returnValue($this->stripeMethod));
     $this->stripeMethod->expects($this->any())->method('setTransactionStatus')->with($this->equalTo('paid'))->will($this->returnValue($this->stripeMethod));
     $this->paymentBridge->expects($this->once())->method('getCurrency')->will($this->returnValue(self::CURRENCY));
     $this->paymentBridge->expects($this->once())->method('getAmount')->will($this->returnValue(self::CART_AMOUNT));
     $cart = array('number' => self::CART_NUMBER, 'exp_month' => self::CART_EXPIRE_MONTH, 'exp_year' => self::CART_EXPIRE_YEAR);
     $chargeParams = array('card' => $cart, 'amount' => self::CART_AMOUNT, 'currency' => strtolower(self::CURRENCY));
     $this->stripeTransactionWrapper->expects($this->once())->method('create')->with($chargeParams)->will($this->returnValue(array('paid' => '1', 'id' => '123')));
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderLoad')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->stripeMethod));
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderCreated')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->stripeMethod));
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderDone')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->stripeMethod));
     $this->paymentEventDispatcher->expects($this->any())->method('notifyPaymentOrderFail');
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderSuccess')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->stripeMethod));
     $this->stripeManager->processPayment($this->stripeMethod, self::CART_AMOUNT);
 }