Skip to content

Commit 226354f

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #13133: Magento PayPal checkout fails if email sending fails / other payment does not (by @driskell) - #17590: Braintree: Add unit test for CreditCard/TokenFormatter (by @eduard13) - #17552: Fix proxy generation return type (by @adrian-martinez-interactiv4) - #17540: Fix for #15041 Adding a new fieldset to the admin category editor changes the position of the 'General' fieldset (by @vasilii-b) - #17526: Fixed undefinded shipping method name issue #17492 (by @gelanivishal) - #17491: [Backport] Fix incorrect image magnifier size bug in Safari (by @dannynimmo) - #16021: Introduce Block Config Source (by @thomas-blackbird) - #15369: Fixed review list ajax if product not exist redirect to 404 page #13102 (by @Ananth747) - #15357: 6305 - Resolved product custom option title save issue (by @Madhumalak) - #14973: Fix unstable session manager (by @elioermini) Fixed GitHub Issues: - #15041: Adding a new fieldset to the admin category editor changes the position of the 'General' fieldset. (reported by @leoquijano) has been fixed in #17540 by @vasilii-b in 2.2-develop branch Related commits: 1. 1e1647a - #17492: "- undefined" displayed in checkout summary when shipping method name is not set (reported by @krzksz) has been fixed in #17526 by @gelanivishal in 2.2-develop branch Related commits: 1. c789fb2 2. 7aecb1f - #17416: Product image zoom (magnifier) is broken in Safari (reported by @dannynimmo) has been fixed in #17491 by @dannynimmo in 2.2-develop branch Related commits: 1. 0f59151 - #13102: review/product/listAjax/id/{{non existent id}/ (reported by @ruthger92) has been fixed in #15369 by @Ananth747 in 2.2-develop branch Related commits: 1. a1d0e3b 2. b81bf67 3. b0848c4 4. f5bd1c6 - #6305: Can't save Customizable options (reported by @bachlee89) has been fixed in #15357 by @Madhumalak in 2.2-develop branch Related commits: 1. 474946c 2. 9dd8945 3. 641c556 4. 3c444ce - #12362: Concurrent (quick reload) requests on checkout cause cart to empty - related to session_regenerate_id (reported by @minlare) has been fixed in #14973 by @elioermini in 2.2-develop branch Related commits: 1. 5e66f1b 2. 8f033ac 3. 6ee737b 4. d63c2c3 5. 5dbce2a 6. b186567 7. eabccc8
2 parents 0e835c9 + c120002 commit 226354f

File tree

20 files changed

+372
-63
lines changed

20 files changed

+372
-63
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Braintree\Test\Unit\Model\InstantPurchase\CreditCard;
9+
10+
use Magento\Braintree\Model\InstantPurchase\CreditCard\TokenFormatter as CreditCardTokenFormatter;
11+
use Magento\Vault\Api\Data\PaymentTokenInterface;
12+
use PHPUnit\Framework\TestCase;
13+
use PHPUnit_Framework_MockObject_MockObject;
14+
15+
class TokenFormatterTest extends TestCase
16+
{
17+
/**
18+
* @var PaymentTokenInterface|PHPUnit_Framework_MockObject_MockObject
19+
*/
20+
private $paymentTokenMock;
21+
22+
/**
23+
* @var CreditCardTokenFormatter
24+
*/
25+
private $creditCardTokenFormatter;
26+
27+
/**
28+
* @var array
29+
*/
30+
private $tokenDetails = [
31+
'type' => 'visa',
32+
'maskedCC' => '1111************9999',
33+
'expirationDate' => '01-01-2020'
34+
];
35+
36+
/**
37+
* Set Up
38+
*
39+
* @return void
40+
*/
41+
protected function setUp()
42+
{
43+
$this->paymentTokenMock = $this->getMockBuilder(PaymentTokenInterface::class)
44+
->getMockForAbstractClass();
45+
46+
$this->creditCardTokenFormatter = new CreditCardTokenFormatter();
47+
}
48+
49+
/**
50+
* Testing the payment format with a known credit card type
51+
*
52+
* @return void
53+
*/
54+
public function testFormatPaymentTokenWithKnownCardType()
55+
{
56+
$this->tokenDetails['type'] = key(CreditCardTokenFormatter::$baseCardTypes);
57+
$this->paymentTokenMock->expects($this->once())
58+
->method('getTokenDetails')
59+
->willReturn(json_encode($this->tokenDetails));
60+
61+
$formattedString = sprintf(
62+
'%s: %s, %s: %s (%s: %s)',
63+
__('Credit Card'),
64+
reset(CreditCardTokenFormatter::$baseCardTypes),
65+
__('ending'),
66+
$this->tokenDetails['maskedCC'],
67+
__('expires'),
68+
$this->tokenDetails['expirationDate']
69+
);
70+
71+
self::assertEquals(
72+
$formattedString,
73+
$this->creditCardTokenFormatter->formatPaymentToken($this->paymentTokenMock)
74+
);
75+
}
76+
77+
/**
78+
* Testing the payment format with a unknown credit card type
79+
*
80+
* @return void
81+
*/
82+
public function testFormatPaymentTokenWithUnknownCardType()
83+
{
84+
$this->paymentTokenMock->expects($this->once())
85+
->method('getTokenDetails')
86+
->willReturn(json_encode($this->tokenDetails));
87+
88+
$formattedString = sprintf(
89+
'%s: %s, %s: %s (%s: %s)',
90+
__('Credit Card'),
91+
$this->tokenDetails['type'],
92+
__('ending'),
93+
$this->tokenDetails['maskedCC'],
94+
__('expires'),
95+
$this->tokenDetails['expirationDate']
96+
);
97+
98+
self::assertEquals(
99+
$formattedString,
100+
$this->creditCardTokenFormatter->formatPaymentToken($this->paymentTokenMock)
101+
);
102+
}
103+
104+
/**
105+
* Testing the payment format with wrong card data
106+
*
107+
* @return void
108+
*/
109+
public function testFormatPaymentTokenWithWrongData()
110+
{
111+
unset($this->tokenDetails['type']);
112+
$this->paymentTokenMock->expects($this->once())
113+
->method('getTokenDetails')
114+
->willReturn(json_encode($this->tokenDetails));
115+
self::expectException('\InvalidArgumentException');
116+
117+
$this->creditCardTokenFormatter->formatPaymentToken($this->paymentTokenMock);
118+
}
119+
}

app/code/Magento/Catalog/Model/Product/Option/Validator/DefaultValidator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ protected function isValidOptionTitle($title, $storeId)
106106
if ($storeId > \Magento\Store\Model\Store::DEFAULT_STORE_ID && $title === null) {
107107
return true;
108108
}
109-
if ($this->isEmpty($title)) {
109+
110+
// checking whether title is null and is empty string
111+
if ($title === null || $title === '') {
110112
return false;
111113
}
112114

app/code/Magento/Catalog/Model/ResourceModel/Product/Option/Value.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ protected function _saveValueTitles(AbstractModel $object)
256256
$object->unsetData('title');
257257
}
258258

259-
if ($object->getTitle()) {
259+
/*** Checking whether title is not null ***/
260+
if ($object->getTitle()!= null) {
260261
if ($existInCurrentStore) {
261262
if ($storeId == $object->getStoreId()) {
262263
$where = [

app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</settings>
4343
</dataProvider>
4444
</dataSource>
45-
<fieldset name="general">
45+
<fieldset name="general" sortOrder="5">
4646
<settings>
4747
<collapsible>false</collapsible>
4848
<label/>

app/code/Magento/Checkout/view/frontend/web/js/view/summary/shipping.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,19 @@ define([
2121
* @return {*}
2222
*/
2323
getShippingMethodTitle: function () {
24-
var shippingMethod;
24+
var shippingMethod,
25+
shippingMethodTitle = '';
2526

2627
if (!this.isCalculated()) {
2728
return '';
2829
}
2930
shippingMethod = quote.shippingMethod();
3031

31-
return shippingMethod ? shippingMethod['carrier_title'] + ' - ' + shippingMethod['method_title'] : '';
32+
if (typeof shippingMethod['method_title'] !== 'undefined') {
33+
shippingMethodTitle = ' - ' + shippingMethod['method_title'];
34+
}
35+
36+
return shippingMethod ? shippingMethod['carrier_title'] + shippingMethodTitle : '';
3237
},
3338

3439
/**
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Cms\Model\Config\Source;
7+
8+
use Magento\Cms\Model\ResourceModel\Block\CollectionFactory;
9+
10+
/**
11+
* Class Block
12+
*/
13+
class Block implements \Magento\Framework\Option\ArrayInterface
14+
{
15+
/**
16+
* @var array
17+
*/
18+
private $options;
19+
20+
/**
21+
* @var CollectionFactory
22+
*/
23+
private $collectionFactory;
24+
25+
/**
26+
* @param CollectionFactory $collectionFactory
27+
*/
28+
public function __construct(
29+
CollectionFactory $collectionFactory
30+
) {
31+
$this->collectionFactory = $collectionFactory;
32+
}
33+
34+
/**
35+
* To option array
36+
*
37+
* @return array
38+
*/
39+
public function toOptionArray()
40+
{
41+
if (!$this->options) {
42+
$this->options = $this->collectionFactory->create()->toOptionIdArray();
43+
}
44+
return $this->options;
45+
}
46+
}

app/code/Magento/Cms/Model/ResourceModel/AbstractCollection.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,32 @@ public function getSelectCountSql()
176176

177177
return $countSelect;
178178
}
179+
180+
/**
181+
* Returns pairs identifier - title for unique identifiers
182+
* and pairs identifier|entity_id - title for non-unique after first
183+
*
184+
* @return array
185+
*/
186+
public function toOptionIdArray()
187+
{
188+
$res = [];
189+
$existingIdentifiers = [];
190+
foreach ($this as $item) {
191+
$identifier = $item->getData('identifier');
192+
193+
$data['value'] = $identifier;
194+
$data['label'] = $item->getData('title');
195+
196+
if (in_array($identifier, $existingIdentifiers)) {
197+
$data['value'] .= '|' . $item->getData($this->getIdFieldName());
198+
} else {
199+
$existingIdentifiers[] = $identifier;
200+
}
201+
202+
$res[] = $data;
203+
}
204+
205+
return $res;
206+
}
179207
}

app/code/Magento/Cms/Model/ResourceModel/Page/Collection.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,34 +51,6 @@ protected function _construct()
5151
$this->_map['fields']['store'] = 'store_table.store_id';
5252
}
5353

54-
/**
55-
* Returns pairs identifier - title for unique identifiers
56-
* and pairs identifier|page_id - title for non-unique after first
57-
*
58-
* @return array
59-
*/
60-
public function toOptionIdArray()
61-
{
62-
$res = [];
63-
$existingIdentifiers = [];
64-
foreach ($this as $item) {
65-
$identifier = $item->getData('identifier');
66-
67-
$data['value'] = $identifier;
68-
$data['label'] = $item->getData('title');
69-
70-
if (in_array($identifier, $existingIdentifiers)) {
71-
$data['value'] .= '|' . $item->getData('page_id');
72-
} else {
73-
$existingIdentifiers[] = $identifier;
74-
}
75-
76-
$res[] = $data;
77-
}
78-
79-
return $res;
80-
}
81-
8254
/**
8355
* Set first store flag
8456
*
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Cms\Test\Unit\Model\Config\Source;
7+
8+
/**
9+
* Class BlockTest
10+
*/
11+
class BlockTest extends \PHPUnit\Framework\TestCase
12+
{
13+
/**
14+
* @var \Magento\Cms\Model\ResourceModel\Block\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
15+
*/
16+
protected $collectionFactory;
17+
18+
/**
19+
* @var \Magento\Cms\Model\Config\Source\Block
20+
*/
21+
protected $block;
22+
23+
/**
24+
* Set up
25+
*
26+
* @return void
27+
*/
28+
protected function setUp()
29+
{
30+
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
31+
32+
$this->collectionFactory = $this->createPartialMock(
33+
\Magento\Cms\Model\ResourceModel\Block\CollectionFactory::class,
34+
['create']
35+
);
36+
37+
$this->block = $objectManager->getObject(
38+
\Magento\Cms\Model\Config\Source\Block::class,
39+
[
40+
'collectionFactory' => $this->collectionFactory,
41+
]
42+
);
43+
}
44+
45+
/**
46+
* Run test toOptionArray method
47+
*
48+
* @return void
49+
*/
50+
public function testToOptionArray()
51+
{
52+
$blockCollectionMock = $this->createMock(\Magento\Cms\Model\ResourceModel\Block\Collection::class);
53+
54+
$this->collectionFactory->expects($this->once())
55+
->method('create')
56+
->will($this->returnValue($blockCollectionMock));
57+
58+
$blockCollectionMock->expects($this->once())
59+
->method('toOptionIdArray')
60+
->will($this->returnValue('return-value'));
61+
62+
$this->assertEquals('return-value', $this->block->toOptionArray());
63+
}
64+
}

app/code/Magento/Paypal/Model/Express/Checkout.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,12 @@ public function place($token, $shippingMethodCode = null)
810810
case \Magento\Sales\Model\Order::STATE_PROCESSING:
811811
case \Magento\Sales\Model\Order::STATE_COMPLETE:
812812
case \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW:
813-
if (!$order->getEmailSent()) {
814-
$this->orderSender->send($order);
813+
try {
814+
if (!$order->getEmailSent()) {
815+
$this->orderSender->send($order);
816+
}
817+
} catch (\Exception $e) {
818+
$this->_logger->critical($e);
815819
}
816820
$this->_checkoutSession->start();
817821
break;

0 commit comments

Comments
 (0)