/**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Some transactions are already settled or voided and cannot be voided.
  */
 public function testVoidInvalidState()
 {
     $orderId = 1005;
     $paymentObject = $this->setupPaymentObjectForVoid($orderId);
     $transactions = ['1' => \Braintree_Transaction::factory(['id' => '1', 'status' => \Braintree_Transaction::SETTLED])];
     $this->setupTransactionIds($orderId, array_keys($transactions));
     $index = 0;
     foreach ($transactions as $id => $transaction) {
         $this->braintreeTransactionMock->expects($this->at($index))->method('find')->with($id)->willReturn($transaction);
         $index++;
     }
     $this->model->void($paymentObject);
 }
Пример #2
0
 /**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage There was an error capturing the transaction: error.
  */
 public function testCaptureError()
 {
     $amount = self::AUTH_AMOUNT;
     $paymentId = 1005;
     $paymentObject = $this->setupPaymentObjectForCapture($paymentId);
     //setup braintree error response
     $resultError = $this->getMockBuilder('\\Braintree_Result_Error')->disableOriginalConstructor()->getMock();
     $this->errorHelperMock->expects($this->once())->method('parseBraintreeError')->with($resultError)->willReturn(new \Magento\Framework\Phrase('error'));
     $this->braintreeTransactionMock->expects($this->once())->method('submitForSettlement')->with(self::AUTH_TRAN_ID, $amount)->willReturn($resultError);
     $this->psrLoggerMock->expects($this->once())->method('critical');
     $this->model->capture($paymentObject, $amount);
 }