Skip to content

Commit 618ba22

Browse files
author
Oleksii Korshenko
committed
MAGETWO-87333: Broken Mainline Test Magento\Paypal\Controller\ExpressTest::testReturnAction
- isolated the test
1 parent fce58fc commit 618ba22

File tree

1 file changed

+87
-88
lines changed

1 file changed

+87
-88
lines changed

dev/tests/integration/testsuite/Magento/Paypal/Controller/ExpressTest.php

Lines changed: 87 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -138,92 +138,91 @@ public function testStartActionCustomerToQuote()
138138
);
139139
}
140140

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

0 commit comments

Comments
 (0)