Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ExpressTest.php
Go to the documentation of this file.
1 <?php
8 
10 
14 abstract class ExpressTest extends \PHPUnit\Framework\TestCase
15 {
17  protected $model;
18 
19  protected $name = '';
20 
22  protected $customerSession;
23 
25  protected $checkoutSession;
26 
28  protected $checkoutFactory;
29 
31  protected $session;
32 
34  protected $quote;
35 
37  protected $customerData;
38 
40  protected $checkout;
41 
43  protected $request;
44 
46  protected $redirect;
47 
49  protected $response;
50 
52  protected $config;
53 
55  protected $messageManager;
56 
59 
60  protected function setUp()
61  {
62  $this->markTestIncomplete();
63  $this->messageManager = $this->getMockForAbstractClass(\Magento\Framework\Message\ManagerInterface::class);
64  $this->config = $this->createMock(\Magento\Paypal\Model\Config::class);
65  $this->request = $this->createMock(\Magento\Framework\App\Request\Http::class);
66  $this->quote = $this->createMock(\Magento\Quote\Model\Quote::class);
67  $this->quote->expects($this->any())
68  ->method('hasItems')
69  ->will($this->returnValue(true));
70  $this->redirect = $this->getMockForAbstractClass(\Magento\Framework\App\Response\RedirectInterface::class);
71  $this->response = $this->createMock(\Magento\Framework\App\Response\Http::class);
72  $this->customerData = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class);
73  $this->checkout = $this->createMock(\Magento\Paypal\Model\Express\Checkout::class);
74  $this->customerSession = $this->createMock(\Magento\Customer\Model\Session::class);
75  $this->customerSession->expects($this->any())
76  ->method('getCustomerDataObject')
77  ->will($this->returnValue($this->customerData));
78  $this->checkoutSession = $this->createMock(\Magento\Checkout\Model\Session::class);
79  $this->checkoutFactory = $this->createMock(\Magento\Paypal\Model\Express\Checkout\Factory::class);
80  $this->checkoutFactory->expects($this->any())
81  ->method('create')
82  ->will($this->returnValue($this->checkout));
83  $this->checkoutSession->expects($this->any())
84  ->method('getQuote')
85  ->will($this->returnValue($this->quote));
86  $this->session = $this->createMock(\Magento\Framework\Session\Generic::class);
87  $objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
88  $this->objectManagerCallback = function ($className) {
89  if ($className == \Magento\Paypal\Model\Config::class) {
90  return $this->config;
91  }
92  return $this->createMock($className);
93  };
94  $objectManager->expects($this->any())
95  ->method('get')
96  ->will($this->returnCallback(function ($className) {
97  return call_user_func($this->objectManagerCallback, $className);
98  }));
99  $objectManager->expects($this->any())
100  ->method('create')
101  ->will($this->returnCallback(function ($className) {
102  return call_user_func($this->objectManagerCallback, $className);
103  }));
104 
105  $helper = new ObjectManagerHelper($this);
106  $this->model = $helper->getObject(
107  '\\Magento\\Paypal\\Controller\\Express\\' . $this->name,
108  [
109  'messageManager' => $this->messageManager,
110  'response' => $this->response,
111  'redirect' => $this->redirect,
112  'request' => $this->request,
113  'customerSession' => $this->customerSession,
114  'checkoutSession' => $this->checkoutSession,
115  'checkoutFactory' => $this->checkoutFactory,
116  'paypalSession' => $this->session,
117  'objectManager' => $objectManager,
118  ]
119  );
120  }
121 }
$helper
Definition: iframe.phtml:13
$objectManager
Definition: bootstrap.php:17
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31