Skip to content

Commit a9ad9a0

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-53814' into 2.1-develop-pr46
2 parents adf3be6 + 11b112c commit a9ad9a0

File tree

15 files changed

+321
-224
lines changed

15 files changed

+321
-224
lines changed

app/code/Magento/Checkout/Helper/Data.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'one
305305
'items' => nl2br($items),
306306
'total' => $total,
307307
]
308+
)->setScopeId(
309+
$checkout->getStoreId()
308310
)->setFrom(
309311
$this->scopeConfig->getValue(
310312
'checkout/payment_failed/identity',

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

Lines changed: 53 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
namespace Magento\Checkout\Test\Unit\Helper;
1010

11-
use \Magento\Checkout\Helper\Data;
12-
11+
use Magento\Checkout\Helper\Data;
1312
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
14-
use Magento\Store\Model\ScopeInterface;
1513

14+
/**
15+
* Test for Magento\Checkout\Helper\Data.
16+
*/
1617
class DataTest extends \PHPUnit_Framework_TestCase
1718
{
1819
/**
@@ -38,27 +39,25 @@ class DataTest extends \PHPUnit_Framework_TestCase
3839
/**
3940
* @var \PHPUnit_Framework_MockObject_MockObject
4041
*/
41-
protected $_checkoutSession;
42+
private $_checkoutSession;
4243

4344
/**
4445
* @var \PHPUnit_Framework_MockObject_MockObject
4546
*/
46-
protected $_scopeConfig;
47+
private $_scopeConfig;
4748

4849
/**
4950
* @var \PHPUnit_Framework_MockObject_MockObject
5051
*/
51-
protected $_collectionFactory;
52+
private $_eventManager;
5253

5354
/**
54-
* @var \PHPUnit_Framework_MockObject_MockObject
55+
* @inheritdoc
5556
*/
56-
protected $_eventManager;
57-
5857
protected function setUp()
5958
{
6059
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
61-
$className = 'Magento\Checkout\Helper\Data';
60+
$className = \Magento\Checkout\Helper\Data::class;
6261
$arguments = $objectManagerHelper->getConstructArguments($className);
6362
/** @var \Magento\Framework\App\Helper\Context $context */
6463
$context = $arguments['context'];
@@ -74,50 +73,50 @@ protected function setUp()
7473
'checkout/payment_failed/template',
7574
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
7675
8,
77-
'fixture_email_template_payment_failed'
76+
'fixture_email_template_payment_failed',
7877
],
7978
[
8079
'checkout/payment_failed/receiver',
8180
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
8281
8,
83-
'sysadmin'
82+
'sysadmin',
8483
],
8584
[
8685
'trans_email/ident_sysadmin/email',
8786
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
8887
8,
89-
'sysadmin@example.com'
88+
'sysadmin@example.com',
9089
],
9190
[
9291
'trans_email/ident_sysadmin/name',
9392
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
9493
8,
95-
'System Administrator'
94+
'System Administrator',
9695
],
9796
[
9897
'checkout/payment_failed/identity',
9998
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
10099
8,
101-
'noreply@example.com'
100+
'noreply@example.com',
102101
],
103102
[
104103
'carriers/ground/title',
105104
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
106105
null,
107-
'Ground Shipping'
106+
'Ground Shipping',
108107
],
109108
[
110109
'payment/fixture-payment-method/title',
111110
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
112111
null,
113-
'Check Money Order'
112+
'Check Money Order',
114113
],
115114
[
116115
'checkout/options/onepage_checkout_enabled',
117116
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
118117
null,
119-
'One Page Checkout'
120-
]
118+
'One Page Checkout',
119+
],
121120
]
122121
)
123122
);
@@ -166,6 +165,16 @@ public function testSendPaymentFailedEmail()
166165
$this->returnSelf()
167166
);
168167

168+
$this->_transportBuilder->expects(
169+
$this->once()
170+
)->method(
171+
'setScopeId'
172+
)->with(
173+
8
174+
)->will(
175+
$this->returnSelf()
176+
);
177+
169178
$this->_transportBuilder->expects(
170179
$this->once()
171180
)->method(
@@ -203,7 +212,7 @@ public function testSendPaymentFailedEmail()
203212
'shippingMethod' => 'Ground Shipping',
204213
'paymentMethod' => 'Check Money Order',
205214
'items' => "Product One x 2 USD 10<br />\nProduct Two x 3 USD 60<br />\n",
206-
'total' => 'USD 70'
215+
'total' => 'USD 70',
207216
]
208217
)->will(
209218
$this->returnSelf()
@@ -215,17 +224,17 @@ public function testSendPaymentFailedEmail()
215224
)->method(
216225
'getTransport'
217226
)->will(
218-
$this->returnValue($this->getMock('Magento\Framework\Mail\TransportInterface'))
227+
$this->returnValue($this->getMock(\Magento\Framework\Mail\TransportInterface::class))
219228
);
220229

221230
$this->_translator->expects($this->at(1))->method('suspend');
222231
$this->_translator->expects($this->at(1))->method('resume');
223232

224-
$productOne = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false);
233+
$productOne = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false);
225234
$productOne->expects($this->once())->method('getName')->will($this->returnValue('Product One'));
226235
$productOne->expects($this->once())->method('getFinalPrice')->with(2)->will($this->returnValue(10));
227236

228-
$productTwo = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false);
237+
$productTwo = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false);
229238
$productTwo->expects($this->once())->method('getName')->will($this->returnValue('Product Two'));
230239
$productTwo->expects($this->once())->method('getFinalPrice')->with(3)->will($this->returnValue(60));
231240

@@ -242,8 +251,8 @@ public function testSendPaymentFailedEmail()
242251
'payment' => new \Magento\Framework\DataObject(['method' => 'fixture-payment-method']),
243252
'all_visible_items' => [
244253
new \Magento\Framework\DataObject(['product' => $productOne, 'qty' => 2]),
245-
new \Magento\Framework\DataObject(['product' => $productTwo, 'qty' => 3])
246-
]
254+
new \Magento\Framework\DataObject(['product' => $productTwo, 'qty' => 3]),
255+
],
247256
]
248257
);
249258
$this->assertSame($this->_helper, $this->_helper->sendPaymentFailedEmail($quote, 'test message'));
@@ -259,17 +268,17 @@ public function testGetCheckout()
259268

260269
public function testGetQuote()
261270
{
262-
$quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false);
271+
$quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false);
263272
$this->_checkoutSession->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock));
264273
$this->assertEquals($quoteMock, $this->_helper->getQuote());
265274
}
266275

267276
public function testFormatPrice()
268277
{
269278
$price = 5.5;
270-
$quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false);
279+
$quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false);
271280
$storeMock = $this->getMock(
272-
'Magento\Store\Model\Store',
281+
\Magento\Store\Model\Store::class,
273282
['formatPrice', '__wakeup'],
274283
[],
275284
'',
@@ -300,11 +309,9 @@ public function testCanOnepageCheckout()
300309
public function testIsContextCheckout()
301310
{
302311
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
303-
$context = $objectManagerHelper->getObject(
304-
'Magento\Framework\App\Helper\Context'
305-
);
312+
$context = $objectManagerHelper->getObject(\Magento\Framework\App\Helper\Context::class);
306313
$helper = $objectManagerHelper->getObject(
307-
'Magento\Checkout\Helper\Data',
314+
\Magento\Checkout\Helper\Data::class,
308315
['context' => $context]
309316
);
310317
$context->getRequest()->expects($this->once())->method('getParam')->with('context')->will(
@@ -324,7 +331,7 @@ public function testIsCustomerMustBeLogged()
324331

325332
public function testGetPriceInclTax()
326333
{
327-
$itemMock = $this->getMock('Magento\Framework\DataObject', ['getPriceInclTax'], [], '', false);
334+
$itemMock = $this->getMock(\Magento\Framework\DataObject::class, ['getPriceInclTax'], [], '', false);
328335
$itemMock->expects($this->exactly(2))->method('getPriceInclTax')->will($this->returnValue(5.5));
329336
$this->assertEquals(5.5, $this->_helper->getPriceInclTax($itemMock));
330337
}
@@ -337,17 +344,17 @@ public function testGetPriceInclTaxWithoutTax()
337344
$rowTotal = 15;
338345
$roundPrice = 17;
339346
$expected = 17;
340-
$storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface', [], [], '', false);
347+
$storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false);
341348
$objectManagerHelper = new ObjectManager($this);
342349
$helper = $objectManagerHelper->getObject(
343-
'\Magento\Checkout\Helper\Data',
350+
\Magento\Checkout\Helper\Data::class,
344351
[
345352
'storeManager' => $storeManager,
346353
'priceCurrency' => $this->priceCurrency,
347354
]
348355
);
349356
$itemMock = $this->getMock(
350-
'Magento\Framework\DataObject',
357+
\Magento\Framework\DataObject::class,
351358
['getPriceInclTax', 'getQty', 'getTaxAmount', 'getDiscountTaxCompensation', 'getRowTotal'],
352359
[],
353360
'',
@@ -368,7 +375,7 @@ public function testGetSubtotalInclTax()
368375
{
369376
$rowTotalInclTax = 5.5;
370377
$expected = 5.5;
371-
$itemMock = $this->getMock('Magento\Framework\DataObject', ['getRowTotalInclTax'], [], '', false);
378+
$itemMock = $this->getMock(\Magento\Framework\DataObject::class, ['getRowTotalInclTax'], [], '', false);
372379
$itemMock->expects($this->exactly(2))->method('getRowTotalInclTax')->will($this->returnValue($rowTotalInclTax));
373380
$this->assertEquals($expected, $this->_helper->getSubtotalInclTax($itemMock));
374381
}
@@ -380,7 +387,7 @@ public function testGetSubtotalInclTaxNegative()
380387
$rowTotal = 15;
381388
$expected = 17;
382389
$itemMock = $this->getMock(
383-
'Magento\Framework\DataObject',
390+
\Magento\Framework\DataObject::class,
384391
['getRowTotalInclTax', 'getTaxAmount', 'getDiscountTaxCompensation', 'getRowTotal'],
385392
[],
386393
'',
@@ -396,33 +403,33 @@ public function testGetSubtotalInclTaxNegative()
396403

397404
public function testGetBasePriceInclTaxWithoutQty()
398405
{
399-
$storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface', [], [], '', false);
406+
$storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false);
400407
$objectManagerHelper = new ObjectManager($this);
401408
$helper = $objectManagerHelper->getObject(
402-
'\Magento\Checkout\Helper\Data',
409+
\Magento\Checkout\Helper\Data::class,
403410
[
404411
'storeManager' => $storeManager,
405412
'priceCurrency' => $this->priceCurrency,
406413
]
407414
);
408-
$itemMock = $this->getMock('Magento\Framework\DataObject', ['getQty'], [], '', false);
415+
$itemMock = $this->getMock(\Magento\Framework\DataObject::class, ['getQty'], [], '', false);
409416
$itemMock->expects($this->once())->method('getQty');
410417
$this->priceCurrency->expects($this->once())->method('round');
411418
$helper->getPriceInclTax($itemMock);
412419
}
413420

414421
public function testGetBasePriceInclTax()
415422
{
416-
$storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface', [], [], '', false);
423+
$storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false);
417424
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
418425
$helper = $objectManagerHelper->getObject(
419-
'\Magento\Checkout\Helper\Data',
426+
\Magento\Checkout\Helper\Data::class,
420427
[
421428
'storeManager' => $storeManager,
422429
'priceCurrency' => $this->priceCurrency,
423430
]
424431
);
425-
$itemMock = $this->getMock('Magento\Framework\DataObject', ['getQty', 'getQtyOrdered'], [], '', false);
432+
$itemMock = $this->getMock(\Magento\Framework\DataObject::class, ['getQty', 'getQtyOrdered'], [], '', false);
426433
$itemMock->expects($this->once())->method('getQty')->will($this->returnValue(false));
427434
$itemMock->expects($this->exactly(2))->method('getQtyOrdered')->will($this->returnValue(5.5));
428435
$this->priceCurrency->expects($this->once())->method('round');
@@ -432,7 +439,7 @@ public function testGetBasePriceInclTax()
432439
public function testGetBaseSubtotalInclTax()
433440
{
434441
$itemMock = $this->getMock(
435-
'Magento\Framework\DataObject',
442+
\Magento\Framework\DataObject::class,
436443
['getBaseTaxAmount', 'getBaseDiscountTaxCompensation', 'getBaseRowTotal'],
437444
[],
438445
'',
@@ -446,7 +453,7 @@ public function testGetBaseSubtotalInclTax()
446453

447454
public function testIsAllowedGuestCheckoutWithoutStore()
448455
{
449-
$quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false);
456+
$quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false);
450457
$store = null;
451458
$quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue(1));
452459
$this->_scopeConfig->expects($this->once())

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,11 +1102,13 @@ protected function sendEmailTemplate(
11021102
$email = $customer->getEmail();
11031103
}
11041104

1105-
$transport = $this->transportBuilder->setTemplateIdentifier($templateId)->setTemplateOptions(
1106-
['area' => Area::AREA_FRONTEND, 'store' => $storeId]
1107-
)->setTemplateVars($templateParams)->setFrom(
1108-
$this->scopeConfig->getValue($sender, ScopeInterface::SCOPE_STORE, $storeId)
1109-
)->addTo($email, $this->customerViewHelper->getCustomerName($customer))->getTransport();
1105+
$transport = $this->transportBuilder->setTemplateIdentifier($templateId)
1106+
->setTemplateOptions(['area' => Area::AREA_FRONTEND, 'store' => $storeId])
1107+
->setTemplateVars($templateParams)
1108+
->setScopeId($storeId)
1109+
->setFrom($this->scopeConfig->getValue($sender, ScopeInterface::SCOPE_STORE, $storeId))
1110+
->addTo($email, $this->customerViewHelper->getCustomerName($customer))
1111+
->getTransport();
11101112

11111113
$transport->sendMessage();
11121114

app/code/Magento/Customer/Model/Customer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,8 @@ protected function _sendEmailTemplate($template, $sender, $templateParams = [],
830830
['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId]
831831
)->setTemplateVars(
832832
$templateParams
833+
)->setScopeId(
834+
$storeId
833835
)->setFrom(
834836
$this->_scopeConfig->getValue($sender, ScopeInterface::SCOPE_STORE, $storeId)
835837
)->addTo(

app/code/Magento/Customer/Model/EmailNotification.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ private function sendEmailTemplate(
232232
$transport = $this->transportBuilder->setTemplateIdentifier($templateId)
233233
->setTemplateOptions(['area' => 'frontend', 'store' => $storeId])
234234
->setTemplateVars($templateParams)
235+
->setScopeId($storeId)
235236
->setFrom($this->scopeConfig->getValue($sender, 'store', $storeId))
236237
->addTo($email, $this->customerViewHelper->getCustomerName($customer))
237238
->getTransport();

0 commit comments

Comments
 (0)