Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ReturnActionTest.php
Go to the documentation of this file.
1 <?php
8 
10 {
11  protected $name = 'ReturnAction';
12 
16  protected function _expectRedirect($path = '*/*/review')
17  {
18  $this->redirect->expects($this->once())
19  ->method('redirect')
20  ->with($this->anything(), $path, []);
21  }
22 
24  {
25  $this->request->expects($this->once())
26  ->method('getParam')
27  ->with('retry_authorization')
28  ->will($this->returnValue('true'));
29  $this->checkoutSession->expects($this->once())
30  ->method('__call')
31  ->with('getPaypalTransactionData')
32  ->will($this->returnValue(['any array']));
33  $this->_expectForwardPlaceOrder();
34  $this->model->execute();
35  }
36 
40  public function trueFalseDataProvider()
41  {
42  return [[true], [false]];
43  }
44 
49  public function testExecute($canSkipOrderReviewStep)
50  {
51  $this->checkoutSession->expects($this->at(0))
52  ->method('__call')
53  ->with('unsPaypalTransactionData');
54  $this->checkout->expects($this->once())
55  ->method('canSkipOrderReviewStep')
56  ->will($this->returnValue($canSkipOrderReviewStep));
57  if ($canSkipOrderReviewStep) {
58  $this->_expectForwardPlaceOrder();
59  } else {
60  $this->_expectRedirect();
61  }
62  $this->model->execute();
63  }
64 
65  private function _expectForwardPlaceOrder()
66  {
67  $this->request->expects($this->once())
68  ->method('setActionName')
69  ->with('placeOrder');
70  $this->request->expects($this->once())
71  ->method('setDispatched')
72  ->with(false);
73  }
74 }