Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
ExpressTest Class Reference
Inheritance diagram for ExpressTest:
AbstractController

Public Member Functions

 testReviewAction ()
 
 testReturnAction ()
 
- Public Member Functions inherited from AbstractController
 getRequest ()
 
 getResponse ()
 
 assert404NotFound ()
 
 assertHeaderPcre ($headerName, $valueRegex)
 
 assertRedirect (\PHPUnit\Framework\Constraint\Constraint $urlConstraint=null)
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractController
 _getBootstrap ()
 
 setUp ()
 
 tearDown ()
 
 assertPostConditions ()
 
 getMessages ( $messageType=null, $messageManagerClass=\Magento\Framework\Message\Manager::class)
 
- Protected Attributes inherited from AbstractController
 $_runCode = ''
 
 $_runScope = 'store'
 
 $_runOptions = []
 
 $_request
 
 $_response
 
 $_objectManager
 
 $_assertSessionErrors = false
 

Detailed Description

Definition at line 22 of file ExpressTest.php.

Member Function Documentation

◆ testReturnAction()

testReturnAction ( )

Test return action with configurable product.

@magentoDataFixture Magento/Paypal/_files/quote_express_configurable.php

Definition at line 146 of file ExpressTest.php.

147  {
148  $quote = $this->_objectManager->create(Quote::class);
149  $quote->load('test_cart_with_configurable', 'reserved_order_id');
150 
151  $payment = $quote->getPayment();
152  $payment->setMethod(\Magento\Paypal\Model\Config::METHOD_WPP_EXPRESS)
153  ->setAdditionalInformation(\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID, 123);
154 
155  $quote->save();
156 
157  $this->_objectManager->removeSharedInstance(Session::class);
158  $session = $this->_objectManager->get(Session::class);
159  $session->setQuoteId($quote->getId());
160 
161  $nvpMethods = [
162  'setToken',
163  'setPayerId',
164  'setAmount',
165  'setPaymentAction',
166  'setNotifyUrl',
167  'setInvNum',
168  'setCurrencyCode',
169  'setPaypalCart',
170  'setIsLineItemsEnabled',
171  'setAddress',
172  'setBillingAddress',
173  'callDoExpressCheckoutPayment',
174  'callGetExpressCheckoutDetails',
175  'getExportedBillingAddress'
176  ];
177 
178  $nvpMock = $this->getMockBuilder(Nvp::class)
179  ->setMethods($nvpMethods)
180  ->disableOriginalConstructor()
181  ->getMock();
182 
183  foreach ($nvpMethods as $method) {
184  $nvpMock->method($method)
185  ->willReturnSelf();
186  }
187 
188  $apiFactoryMock = $this->getMockBuilder(ApiFactory::class)
189  ->disableOriginalConstructor()
190  ->setMethods(['create'])
191  ->getMock();
192 
193  $apiFactoryMock->method('create')
194  ->with(Nvp::class)
195  ->willReturn($nvpMock);
196 
197  $this->_objectManager->addSharedInstance($apiFactoryMock, ApiFactory::class);
198 
199  $sessionMock = $this->getMockBuilder(GenericSession::class)
200  ->setMethods(['getExpressCheckoutToken'])
201  ->setConstructorArgs(
202  [
203  $this->_objectManager->get(\Magento\Framework\App\Request\Http::class),
204  $this->_objectManager->get(\Magento\Framework\Session\SidResolverInterface::class),
205  $this->_objectManager->get(\Magento\Framework\Session\Config\ConfigInterface::class),
206  $this->_objectManager->get(\Magento\Framework\Session\SaveHandlerInterface::class),
207  $this->_objectManager->get(\Magento\Framework\Session\ValidatorInterface::class),
208  $this->_objectManager->get(\Magento\Framework\Session\StorageInterface::class),
209  $this->_objectManager->get(\Magento\Framework\Stdlib\CookieManagerInterface::class),
210  $this->_objectManager->get(\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class),
211  $this->_objectManager->get(\Magento\Framework\App\State::class),
212  ]
213  )
214  ->getMock();
215 
216  $sessionMock->method('getExpressCheckoutToken')
217  ->willReturn(true);
218 
219  $this->_objectManager->addSharedInstance($sessionMock, PaypalSession::class);
220 
221  $this->dispatch('paypal/express/returnAction');
222  $this->assertRedirect($this->stringContains('checkout/onepage/success'));
223 
224  $this->_objectManager->removeSharedInstance(ApiFactory::class);
225  $this->_objectManager->removeSharedInstance(PaypalSession::class);
226  }
assertRedirect(\PHPUnit\Framework\Constraint\Constraint $urlConstraint=null)
$quote
$payment
Definition: order.php:17
$method
Definition: info.phtml:13

◆ testReviewAction()

testReviewAction ( )

@magentoDataFixture Magento/Sales/_files/quote.php @magentoDataFixture Magento/Paypal/_files/quote_payment.php

Definition at line 28 of file ExpressTest.php.

29  {
30  $quote = Bootstrap::getObjectManager()->create(Quote::class);
31  $quote->load('test01', 'reserved_order_id');
33  Session::class
34  )->setQuoteId(
35  $quote->getId()
36  );
37 
38  $this->dispatch('paypal/express/review');
39 
40  $html = $this->getResponse()->getBody();
41  $this->assertContains('Simple Product', $html);
42  $this->assertContains('Review', $html);
43  $this->assertContains('/paypal/express/placeOrder/', $html);
44  }
$quote

The documentation for this class was generated from the following file: