Inheritance: extends BasePaypal
Example #1
0
 public function testHandleError()
 {
     $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $translator = $this->getMock('Symfony\\Component\\Translation\\TranslatorInterface');
     $paypal = new Paypal($router, $translator);
     $paypal->setLogger($this->getMock('Psr\\Log\\LoggerInterface'));
     $order = $this->getMock('Sonata\\Component\\Order\\OrderInterface');
     $order->expects($this->any())->method('getCreatedAt')->will($this->returnValue(new \DateTime()));
     $order->expects($this->any())->method('isValidated')->will($this->returnValue(true));
     $transaction = $this->getMock('Sonata\\Component\\Payment\\TransactionInterface');
     $transaction->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $paypal->handleError($transaction);
     $transaction = $this->getMock('Sonata\\Component\\Payment\\TransactionInterface');
     $transaction->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $transaction->expects($this->any())->method('getStatusCode')->will($this->returnValue(TransactionInterface::STATUS_ORDER_UNKNOWN));
     $paypal->handleError($transaction);
     $transaction = $this->getMock('Sonata\\Component\\Payment\\TransactionInterface');
     $transaction->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $transaction->expects($this->any())->method('getStatusCode')->will($this->returnValue(TransactionInterface::STATUS_ERROR_VALIDATION));
     $paypal->handleError($transaction);
     $transaction = $this->getMock('Sonata\\Component\\Payment\\TransactionInterface');
     $transaction->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $transaction->expects($this->any())->method('getStatusCode')->will($this->returnValue(TransactionInterface::STATUS_CANCELLED));
     $paypal->handleError($transaction);
     $transaction = $this->getMock('Sonata\\Component\\Payment\\TransactionInterface');
     $transaction->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $transaction->expects($this->any())->method('getStatusCode')->will($this->returnValue(TransactionInterface::STATUS_PENDING));
     $transaction->expects($this->any())->method('get')->will($this->returnValue(Paypal::PENDING_REASON_ADDRESS));
     $paypal->handleError($transaction);
 }