Skip to content

Commit aa41f77

Browse files
committed
MAGETWO-92134: [2.2.x] Payment Failed Email is not generated
1 parent bdc6d47 commit aa41f77

File tree

7 files changed

+46
-48
lines changed

7 files changed

+46
-48
lines changed

app/code/Magento/Authorizenet/Model/Directpost.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
143143
* @param \Magento\Framework\Module\ModuleListInterface $moduleList
144144
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
145145
* @param \Magento\Authorizenet\Helper\Data $dataHelper
146-
* @param Directpost\Request\Factory $requestFactory
147-
* @param Directpost\Response\Factory $responseFactory
146+
* @param \Magento\Authorizenet\Model\Directpost\Request\Factory $requestFactory
147+
* @param \Magento\Authorizenet\Model\Directpost\Response\Factory $responseFactory
148148
* @param \Magento\Authorizenet\Model\TransactionService $transactionService
149149
* @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory
150150
* @param \Magento\Sales\Model\OrderFactory $orderFactory
@@ -171,7 +171,7 @@ public function __construct(
171171
\Magento\Authorizenet\Helper\Data $dataHelper,
172172
\Magento\Authorizenet\Model\Directpost\Request\Factory $requestFactory,
173173
\Magento\Authorizenet\Model\Directpost\Response\Factory $responseFactory,
174-
TransactionService $transactionService,
174+
\Magento\Authorizenet\Model\TransactionService $transactionService,
175175
\Magento\Framework\HTTP\ZendClientFactory $httpClientFactory,
176176
\Magento\Sales\Model\OrderFactory $orderFactory,
177177
\Magento\Store\Model\StoreManagerInterface $storeManager,

app/code/Magento/Checkout/Test/Unit/Helper/DataTest.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,32 @@ class DataTest extends \PHPUnit\Framework\TestCase
2323
/**
2424
* @var Data
2525
*/
26-
private $_helper;
26+
private $helper;
2727

2828
/**
2929
* @var \PHPUnit_Framework_MockObject_MockObject
3030
*/
31-
private $_transportBuilder;
31+
private $transportBuilder;
3232

3333
/**
3434
* @var \PHPUnit_Framework_MockObject_MockObject
3535
*/
36-
private $_translator;
36+
private $translator;
3737

3838
/**
3939
* @var \PHPUnit_Framework_MockObject_MockObject
4040
*/
41-
private $_checkoutSession;
41+
private $checkoutSession;
4242

4343
/**
4444
* @var \PHPUnit_Framework_MockObject_MockObject
4545
*/
46-
private $_scopeConfig;
46+
private $scopeConfig;
4747

4848
/**
4949
* @var \PHPUnit_Framework_MockObject_MockObject
5050
*/
51-
private $_eventManager;
51+
private $eventManager;
5252

5353
/**
5454
* @inheritdoc
@@ -60,10 +60,10 @@ protected function setUp()
6060
$arguments = $objectManagerHelper->getConstructArguments($className);
6161
/** @var \Magento\Framework\App\Helper\Context $context */
6262
$context = $arguments['context'];
63-
$this->_translator = $arguments['inlineTranslation'];
64-
$this->_eventManager = $context->getEventManager();
65-
$this->_scopeConfig = $context->getScopeConfig();
66-
$this->_scopeConfig->expects($this->any())
63+
$this->translator = $arguments['inlineTranslation'];
64+
$this->eventManager = $context->getEventManager();
65+
$this->scopeConfig = $context->getScopeConfig();
66+
$this->scopeConfig->expects($this->any())
6767
->method('getValue')
6868
->willReturnMap(
6969
[
@@ -118,16 +118,16 @@ protected function setUp()
118118
]
119119
);
120120

121-
$this->_checkoutSession = $arguments['checkoutSession'];
121+
$this->checkoutSession = $arguments['checkoutSession'];
122122
$arguments['localeDate']->expects($this->any())
123123
->method('formatDateTime')
124124
->willReturn('Oct 02, 2013');
125125

126-
$this->_transportBuilder = $arguments['transportBuilder'];
126+
$this->transportBuilder = $arguments['transportBuilder'];
127127

128128
$this->priceCurrency = $arguments['priceCurrency'];
129129

130-
$this->_helper = $objectManagerHelper->getObject($className, $arguments);
130+
$this->helper = $objectManagerHelper->getObject($className, $arguments);
131131
}
132132

133133
/**
@@ -141,49 +141,49 @@ public function testSendPaymentFailedEmail()
141141
->getMock();
142142
$quoteMock->expects($this->any())->method('getId')->willReturn(1);
143143

144-
$this->assertSame($this->_helper, $this->_helper->sendPaymentFailedEmail($quoteMock, 'test message'));
144+
$this->assertSame($this->helper, $this->helper->sendPaymentFailedEmail($quoteMock, 'test message'));
145145
}
146146

147147
/**
148148
* @return \PHPUnit_Framework_MockObject_MockObject
149149
*/
150150
public function testGetCheckout()
151151
{
152-
$this->assertEquals($this->_checkoutSession, $this->_helper->getCheckout());
152+
$this->assertEquals($this->checkoutSession, $this->helper->getCheckout());
153153
}
154154

155155
public function testGetQuote()
156156
{
157157
$quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
158-
$this->_checkoutSession->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock));
159-
$this->assertEquals($quoteMock, $this->_helper->getQuote());
158+
$this->checkoutSession->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock));
159+
$this->assertEquals($quoteMock, $this->helper->getQuote());
160160
}
161161

162162
public function testFormatPrice()
163163
{
164164
$price = 5.5;
165165
$quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
166166
$storeMock = $this->createPartialMock(\Magento\Store\Model\Store::class, ['formatPrice', '__wakeup']);
167-
$this->_checkoutSession->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock));
167+
$this->checkoutSession->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock));
168168
$quoteMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock));
169169
$this->priceCurrency->expects($this->once())->method('format')->will($this->returnValue('5.5'));
170-
$this->assertEquals('5.5', $this->_helper->formatPrice($price));
170+
$this->assertEquals('5.5', $this->helper->formatPrice($price));
171171
}
172172

173173
public function testConvertPrice()
174174
{
175175
$price = 5.5;
176176
$this->priceCurrency->expects($this->once())->method('convertAndFormat')->willReturn($price);
177-
$this->assertEquals(5.5, $this->_helper->convertPrice($price));
177+
$this->assertEquals(5.5, $this->helper->convertPrice($price));
178178
}
179179

180180
public function testCanOnepageCheckout()
181181
{
182-
$this->_scopeConfig->expects($this->once())->method('getValue')->with(
182+
$this->scopeConfig->expects($this->once())->method('getValue')->with(
183183
'checkout/options/onepage_checkout_enabled',
184184
'store'
185185
)->will($this->returnValue(true));
186-
$this->assertTrue($this->_helper->canOnepageCheckout());
186+
$this->assertTrue($this->helper->canOnepageCheckout());
187187
}
188188

189189
public function testIsContextCheckout()
@@ -204,18 +204,18 @@ public function testIsContextCheckout()
204204

205205
public function testIsCustomerMustBeLogged()
206206
{
207-
$this->_scopeConfig->expects($this->once())->method('isSetFlag')->with(
207+
$this->scopeConfig->expects($this->once())->method('isSetFlag')->with(
208208
'checkout/options/customer_must_be_logged',
209209
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
210210
)->will($this->returnValue(true));
211-
$this->assertTrue($this->_helper->isCustomerMustBeLogged());
211+
$this->assertTrue($this->helper->isCustomerMustBeLogged());
212212
}
213213

214214
public function testGetPriceInclTax()
215215
{
216216
$itemMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getPriceInclTax']);
217217
$itemMock->expects($this->exactly(2))->method('getPriceInclTax')->will($this->returnValue(5.5));
218-
$this->assertEquals(5.5, $this->_helper->getPriceInclTax($itemMock));
218+
$this->assertEquals(5.5, $this->helper->getPriceInclTax($itemMock));
219219
}
220220

221221
public function testGetPriceInclTaxWithoutTax()
@@ -256,7 +256,7 @@ public function testGetSubtotalInclTax()
256256
$expected = 5.5;
257257
$itemMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getRowTotalInclTax']);
258258
$itemMock->expects($this->exactly(2))->method('getRowTotalInclTax')->will($this->returnValue($rowTotalInclTax));
259-
$this->assertEquals($expected, $this->_helper->getSubtotalInclTax($itemMock));
259+
$this->assertEquals($expected, $this->helper->getSubtotalInclTax($itemMock));
260260
}
261261

262262
public function testGetSubtotalInclTaxNegative()
@@ -274,7 +274,7 @@ public function testGetSubtotalInclTaxNegative()
274274
$itemMock->expects($this->once())
275275
->method('getDiscountTaxCompensation')->will($this->returnValue($discountTaxCompensation));
276276
$itemMock->expects($this->once())->method('getRowTotal')->will($this->returnValue($rowTotal));
277-
$this->assertEquals($expected, $this->_helper->getSubtotalInclTax($itemMock));
277+
$this->assertEquals($expected, $this->helper->getSubtotalInclTax($itemMock));
278278
}
279279

280280
public function testGetBasePriceInclTaxWithoutQty()
@@ -321,17 +321,17 @@ public function testGetBaseSubtotalInclTax()
321321
$itemMock->expects($this->once())->method('getBaseTaxAmount');
322322
$itemMock->expects($this->once())->method('getBaseDiscountTaxCompensation');
323323
$itemMock->expects($this->once())->method('getBaseRowTotal');
324-
$this->_helper->getBaseSubtotalInclTax($itemMock);
324+
$this->helper->getBaseSubtotalInclTax($itemMock);
325325
}
326326

327327
public function testIsAllowedGuestCheckoutWithoutStore()
328328
{
329329
$quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
330330
$store = null;
331331
$quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue(1));
332-
$this->_scopeConfig->expects($this->once())
332+
$this->scopeConfig->expects($this->once())
333333
->method('isSetFlag')
334334
->will($this->returnValue(true));
335-
$this->assertTrue($this->_helper->isAllowedGuestCheckout($quoteMock, $store));
335+
$this->assertTrue($this->helper->isAllowedGuestCheckout($quoteMock, $store));
336336
}
337337
}

app/code/Magento/Paypal/Model/Payflowpro.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,6 @@ public function buildBasicRequest()
647647
*
648648
* @param DataObject $response
649649
* @return void
650-
* @throws \Magento\Framework\Exception\LocalizedException
651650
* @throws \Magento\Payment\Gateway\Command\CommandException
652651
* @throws \Magento\Framework\Exception\State\InvalidTransitionException
653652
*/

app/code/Magento/Sales/Model/Service/PaymentFailuresService.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,12 @@ private function getConfigValue(string $configPath, Quote $quote)
189189
* @param Quote $quote
190190
* @return string
191191
*/
192-
private function getShippingMethod(Quote $quote)
192+
private function getShippingMethod(Quote $quote): string
193193
{
194194
$shippingMethod = '';
195-
if ($shippingInfo = $quote->getShippingAddress()->getShippingMethod()) {
195+
$shippingInfo = $quote->getShippingAddress()->getShippingMethod();
196+
197+
if ($shippingInfo) {
196198
$data = explode('_', $shippingInfo);
197199
$shippingMethod = $data[0];
198200
}
@@ -206,12 +208,9 @@ private function getShippingMethod(Quote $quote)
206208
* @param Quote $quote
207209
* @return string
208210
*/
209-
private function getPaymentMethod(Quote $quote)
211+
private function getPaymentMethod(Quote $quote): string
210212
{
211-
$paymentMethod = '';
212-
if ($paymentInfo = $quote->getPayment()) {
213-
$paymentMethod = $paymentInfo->getMethod();
214-
}
213+
$paymentMethod = $quote->getPayment()->getMethod() ?? '';
215214

216215
return $paymentMethod;
217216
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function setUp()
6363
$this->order->getPayment()->setMethod(Config::METHOD_PAYFLOWLINK);
6464

6565
/** @var $quote \Magento\Quote\Model\Quote */
66-
$quote = $this->_objectManager->create(Quote::class)->setStoreid($this->order->getStoreid());
66+
$quote = $this->_objectManager->create(Quote::class)->setStoreid($this->order->getStoreId());
6767

6868
$this->quoteRepository = $this->_objectManager->get(CartRepositoryInterface::class);
6969
$this->quoteRepository->save($quote);
@@ -111,7 +111,7 @@ public function testFormActionIsContentGenerated()
111111
* @magentoConfigFixture current_store paypal/general/business_account merchant_2012050718_biz@example.com
112112
* @return void
113113
*/
114-
public function testCancelAction()
114+
public function testCancelAction(): void
115115
{
116116
$orderId = $this->order->getEntityId();
117117
/** @var \Magento\Sales\Model\Order $order */

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ protected function setUp()
6060

6161
/** @var OrderInterface $order */
6262
$this->order = array_pop($orders);
63-
$this->order->getPayment()->setMethod(Config::METHOD_PAYFLOWLINK);
63+
$this->order->getPayment()->setMethod(Config::METHOD_PAYFLOWADVANCED);
6464

6565
/** @var $quote \Magento\Quote\Model\Quote */
6666
$quote = $this->_objectManager->create(Quote::class)
67-
->setStoreid($this->order->getStoreid());
67+
->setStoreid($this->order->getStoreId());
6868

6969
$this->quoteRepository = $this->_objectManager->get(CartRepositoryInterface::class);
7070
$this->quoteRepository->save($quote);
@@ -104,7 +104,7 @@ public function testFormActionIsContentGenerated()
104104
* @magentoConfigFixture current_store paypal/general/business_account merchant_2012050718_biz@example.com
105105
* @return void
106106
*/
107-
public function testCancelAction()
107+
public function testCancelAction(): void
108108
{
109109
$orderId = $this->order->getEntityId();
110110
/** @var \Magento\Sales\Model\Order $order */
@@ -115,7 +115,7 @@ public function testCancelAction()
115115
$session = $this->_objectManager->get(Session::class);
116116
$session->setQuoteId($quote->getId());
117117
$session->setPaypalStandardQuoteId($quote->getId())->setLastRealOrderId('100000001');
118-
$this->dispatch('paypal/payflow/cancelpayment');
118+
$this->dispatch('paypal/payflowadvanced/cancelpayment');
119119

120120
$order = $this->_objectManager->create(OrderRepositoryInterface::class)->get($orderId);
121121
$this->assertEquals('canceled', $order->getState());

dev/tests/integration/testsuite/Magento/Sales/Model/Service/PaymentFailuresServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function setUp()
5959
* @magentoAppIsolation enabled
6060
* @return void
6161
*/
62-
public function testHandlerWithCustomer()
62+
public function testHandlerWithCustomer(): void
6363
{
6464
$errorMessage = __('Transaction declined.');
6565
$checkoutType = 'custom_checkout';

0 commit comments

Comments
 (0)