コード例 #1
0
 /**
  * Cancel order, return quote to customer
  *
  * @param string $errorMsg
  * @return false|string
  */
 protected function _cancelPayment($errorMsg = '')
 {
     $gotoSection = false;
     $this->_checkoutHelper->cancelCurrentOrder($errorMsg);
     if ($this->_checkoutSession->restoreQuote()) {
         //Redirect to payment step
         $gotoSection = 'paymentMethod';
     }
     return $gotoSection;
 }
コード例 #2
0
 /**
  * @param bool $hasOrderId
  * @param bool $isOrderCancelled
  * @param bool $expectedResult
  * @dataProvider cancelCurrentOrderDataProvider
  */
 public function testCancelCurrentOrder($hasOrderId, $isOrderCancelled, $expectedResult)
 {
     $comment = 'Some test comment';
     $order = $this->_getOrderMock($hasOrderId, ['registerCancellation', 'save']);
     $order->setData('state', $isOrderCancelled ? \Magento\Sales\Model\Order::STATE_CANCELED : 'some another state');
     if ($expectedResult) {
         $order->expects($this->once())->method('registerCancellation')->with($this->equalTo($comment))->will($this->returnSelf());
         $order->expects($this->once())->method('save');
     } else {
         $order->expects($this->never())->method('registerCancellation');
         $order->expects($this->never())->method('save');
     }
     $this->_session->expects($this->any())->method('getLastRealOrder')->will($this->returnValue($order));
     $this->assertEquals($expectedResult, $this->_checkout->cancelCurrentOrder($comment));
 }
コード例 #3
0
ファイル: ReturnUrlTest.php プロジェクト: Zash22/magento
 /**
  * @param $errorMsg
  * @param $errorMsgEscaped
  * @dataProvider checkXSSEscapedDataProvider
  */
 public function testCheckXSSEscaped($errorMsg, $errorMsgEscaped)
 {
     $this->initLayoutMock();
     $this->initOrderMock(self::LAST_REAL_ORDER_ID, Order::STATE_NEW);
     $this->initCheckoutSessionMock(self::LAST_REAL_ORDER_ID, true);
     $this->requestMock->expects($this->once())->method('getParam')->with('RESPMSG')->will($this->returnValue($errorMsg));
     $this->helperCheckoutMock->expects($this->once())->method('cancelCurrentOrder')->with($errorMsgEscaped)->will($this->returnValue(self::LAST_REAL_ORDER_ID));
     $this->blockMock->expects($this->at(0))->method('setData')->with('goto_section', 'paymentMethod')->will($this->returnSelf());
     $this->blockMock->expects($this->at(1))->method('setData')->with('error_msg', __('Your payment has been declined. Please try again.'))->will($this->returnSelf());
     $this->paymentMock->expects($this->once())->method('getMethod')->will($this->returnValue(Config::METHOD_PAYFLOWLINK));
     $this->returnUrl->execute();
 }
コード例 #4
0
 public function testRestoreQuote()
 {
     $this->session->expects(static::once())->method('restoreQuote')->willReturn(true);
     static::assertTrue($this->checkout->restoreQuote());
 }
コード例 #5
0
 /**
  * Customer canceled payment on gateway side.
  *
  * @return void
  */
 public function execute()
 {
     $this->checkoutHelper->cancelCurrentOrder('');
     $this->checkoutHelper->restoreQuote();
     $this->_redirect('checkout', ['_fragment' => 'payment']);
 }