Skip to content

Commit 27f620e

Browse files
author
Denys Rul
committed
Merge branch 'develop' of https://github.com/magento-frontend/magento2ce into MAGETWO-57210
2 parents 57062f5 + a9510d3 commit 27f620e

File tree

32 files changed

+816
-236
lines changed

32 files changed

+816
-236
lines changed

app/code/Magento/Authorizenet/Model/Source/Cctype.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ class Cctype extends PaymentCctype
1717
*/
1818
public function getAllowedTypes()
1919
{
20-
return ['VI', 'MC', 'AE', 'DI'];
20+
return ['VI', 'MC', 'AE', 'DI', 'JCB', 'DN'];
2121
}
2222
}

app/code/Magento/Authorizenet/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<payment>
1111
<authorizenet_directpost>
1212
<active>0</active>
13-
<cctypes>AE,VI,MC,DI</cctypes>
13+
<cctypes>AE,VI,MC,DI,JCB,DN</cctypes>
1414
<debug>0</debug>
1515
<email_customer>0</email_customer>
1616
<login backend_model="Magento\Config\Model\Config\Backend\Encrypted" />

app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
<item name="source" xsi:type="string">catalog_rule</item>
150150
<item name="dataScope" xsi:type="string">customer_group_ids</item>
151151
</item>
152-
<item name="options" xsi:type="object">\Magento\Customer\Model\Customer\Source\GroupSourceInterface</item>
152+
<item name="options" xsi:type="object">\Magento\CatalogRule\Model\Rule\CustomerGroupsOptionsProvider</item>
153153
</argument>
154154
</field>
155155
<field name="from_date">

app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Customer\Controller\Adminhtml\Index;
77

88
use Magento\Framework\Exception\NoSuchEntityException;
9+
use Magento\Framework\Exception\SecurityViolationException;
910

1011
class ResetPassword extends \Magento\Customer\Controller\Adminhtml\Index
1112
{
@@ -40,6 +41,8 @@ public function execute()
4041
$messages = $exception->getMessage();
4142
}
4243
$this->_addSessionErrorMessages($messages);
44+
} catch (SecurityViolationException $exception) {
45+
$this->messageManager->addErrorMessage($exception->getMessage());
4346
} catch (\Exception $exception) {
4447
$this->messageManager->addException(
4548
$exception,

app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ protected function setUp()
143143
$this->messageManager = $this->getMockBuilder(
144144
\Magento\Framework\Message\Manager::class
145145
)->disableOriginalConstructor()->setMethods(
146-
['addSuccess', 'addMessage', 'addException']
146+
['addSuccess', 'addMessage', 'addException', 'addErrorMessage']
147147
)->getMock();
148148

149149
$this->resultRedirectFactoryMock = $this->getMockBuilder(
@@ -332,6 +332,56 @@ public function testResetPasswordActionCoreException()
332332
$this->_testedObject->execute();
333333
}
334334

335+
public function testResetPasswordActionSecurityException()
336+
{
337+
$securityText = 'Security violation.';
338+
$exception = new \Magento\Framework\Exception\SecurityViolationException(__($securityText));
339+
$customerId = 1;
340+
$email = 'some@example.com';
341+
$websiteId = 1;
342+
343+
$this->_request->expects(
344+
$this->once()
345+
)->method(
346+
'getParam'
347+
)->with(
348+
$this->equalTo('customer_id'),
349+
$this->equalTo(0)
350+
)->will(
351+
$this->returnValue($customerId)
352+
);
353+
$customer = $this->getMockForAbstractClass(
354+
\Magento\Customer\Api\Data\CustomerInterface::class,
355+
['getId', 'getEmail', 'getWebsiteId']
356+
);
357+
$customer->expects($this->once())->method('getEmail')->will($this->returnValue($email));
358+
$customer->expects($this->once())->method('getWebsiteId')->will($this->returnValue($websiteId));
359+
$this->_customerRepositoryMock->expects(
360+
$this->once()
361+
)->method(
362+
'getById'
363+
)->with(
364+
$customerId
365+
)->will(
366+
$this->returnValue($customer)
367+
);
368+
$this->_customerAccountManagementMock->expects(
369+
$this->once()
370+
)->method(
371+
'initiatePasswordReset'
372+
)->willThrowException($exception);
373+
374+
$this->messageManager->expects(
375+
$this->once()
376+
)->method(
377+
'addErrorMessage'
378+
)->with(
379+
$this->equalTo($exception->getMessage())
380+
);
381+
382+
$this->_testedObject->execute();
383+
}
384+
335385
public function testResetPasswordActionCoreExceptionWarn()
336386
{
337387
$warningText = 'Warning';

app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/in-context/checkout-express.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ define(
2525
) {
2626
'use strict';
2727

28+
// State of PayPal module initialization
29+
var clientInit = false;
30+
2831
return Component.extend({
2932

3033
defaults: {
@@ -93,15 +96,26 @@ define(
9396
* @returns {Object}
9497
*/
9598
initClient: function () {
99+
var selector = '#' + this.getButtonId();
100+
96101
_.each(this.clientConfig, function (fn, name) {
97102
if (typeof fn === 'function') {
98103
this.clientConfig[name] = fn.bind(this);
99104
}
100105
}, this);
101106

102-
domObserver.get('#' + this.getButtonId(), function () {
103-
paypalExpressCheckout.checkout.setup(this.merchantId, this.clientConfig);
104-
}.bind(this));
107+
if (!clientInit) {
108+
domObserver.get(selector, function () {
109+
paypalExpressCheckout.checkout.setup(this.merchantId, this.clientConfig);
110+
clientInit = true;
111+
domObserver.off(selector);
112+
}.bind(this));
113+
} else {
114+
domObserver.get(selector, function () {
115+
$(selector).on('click', this.clientConfig.click);
116+
domObserver.off(selector);
117+
}.bind(this));
118+
}
105119

106120
return this;
107121
},

app/code/Magento/Sales/Model/OrderRepository.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ public function deleteById($id)
146146
*/
147147
public function save(\Magento\Sales\Api\Data\OrderInterface $entity)
148148
{
149+
/** @var \Magento\Sales\Api\Data\OrderExtensionInterface $extensionAttributes */
150+
$extensionAttributes = $entity->getExtensionAttributes();
151+
if ($entity->getIsNotVirtual() && $extensionAttributes && $extensionAttributes->getShippingAssignments()) {
152+
$shippingAssignments = $extensionAttributes->getShippingAssignments();
153+
if (!empty($shippingAssignments)) {
154+
$shipping = array_shift($shippingAssignments)->getShipping();
155+
$entity->setShippingAddress($shipping->getAddress());
156+
$entity->setShippingMethod($shipping->getMethod());
157+
}
158+
}
149159
$this->metadata->getMapper()->save($entity);
150160
$this->registry[$entity->getEntityId()] = $entity;
151161
return $this->registry[$entity->getEntityId()];

app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,40 @@ public function testGetList()
110110

111111
$this->assertEquals($collectionMock, $this->model->getList($searchCriteriaMock));
112112
}
113+
114+
public function testSave()
115+
{
116+
$mapperMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order::class)
117+
->disableOriginalConstructor()
118+
->getMock();
119+
$orderEntity = $this->getMock(\Magento\Sales\Model\Order::class, [], [], '', false);
120+
$extensionAttributes = $this->getMock(
121+
\Magento\Sales\Api\Data\OrderExtension::class,
122+
['getShippingAssignments'],
123+
[],
124+
'',
125+
false
126+
);
127+
$shippingAssignment = $this->getMockBuilder(\Magento\Sales\Model\Order\ShippingAssignment::class)
128+
->disableOriginalConstructor()
129+
->setMethods(['getShipping'])
130+
->getMock();
131+
$shippingMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Shipping::class)
132+
->disableOriginalConstructor()
133+
->setMethods(['getAddress', 'getMethod'])
134+
->getMock();
135+
$orderEntity->expects($this->once())->method('getExtensionAttributes')->willReturn($extensionAttributes);
136+
$orderEntity->expects($this->once())->method('getIsNotVirtual')->willReturn(true);
137+
$extensionAttributes
138+
->expects($this->any())
139+
->method('getShippingAssignments')
140+
->willReturn([$shippingAssignment]);
141+
$shippingAssignment->expects($this->once())->method('getShipping')->willReturn($shippingMock);
142+
$shippingMock->expects($this->once())->method('getAddress');
143+
$shippingMock->expects($this->once())->method('getMethod');
144+
$this->metadata->expects($this->once())->method('getMapper')->willReturn($mapperMock);
145+
$mapperMock->expects($this->once())->method('save');
146+
$orderEntity->expects($this->any())->method('getEntityId')->willReturn(1);
147+
$this->model->save($orderEntity);
148+
}
113149
}

app/code/Magento/SalesRule/Observer/SalesOrderAfterPlaceObserver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function execute(EventObserver $observer)
5757
{
5858
$order = $observer->getEvent()->getOrder();
5959

60-
if (!$order || $order->getDiscountAmount() == 0) {
60+
if (!$order || !$order->getAppliedRuleIds()) {
6161
return $this;
6262
}
6363

app/code/Magento/SalesRule/Test/Unit/Observer/SalesOrderAfterPlaceObserverTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ public function testSalesOrderAfterPlaceWithoutRuleId()
121121
{
122122
$observer = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false);
123123
$order = $this->initOrderFromEvent($observer);
124-
$discountAmount = 10;
124+
$ruleIds = null;
125125
$order->expects($this->once())
126-
->method('getDiscountAmount')
127-
->will($this->returnValue($discountAmount));
126+
->method('getAppliedRuleIds')
127+
->will($this->returnValue($ruleIds));
128128

129129
$this->ruleFactory->expects($this->never())
130130
->method('create');
@@ -158,14 +158,10 @@ public function testSalesOrderAfterPlace($ruleCustomerId)
158158
$ruleId = 1;
159159
$couponId = 1;
160160
$customerId = 1;
161-
$discountAmount = 10;
162161

163-
$order->expects($this->once())
162+
$order->expects($this->exactly(2))
164163
->method('getAppliedRuleIds')
165164
->will($this->returnValue($ruleId));
166-
$order->expects($this->once())
167-
->method('getDiscountAmount')
168-
->will($this->returnValue($discountAmount));
169165
$order->expects($this->once())
170166
->method('getCustomerId')
171167
->will($this->returnValue($customerId));

0 commit comments

Comments
 (0)