Skip to content

Commit ab1c778

Browse files
author
Dmytro Voskoboinikov
committed
Merge branch '2.1-develop' into 2.1.15-develop
2 parents 0b8b094 + bedf5c1 commit ab1c778

File tree

19 files changed

+413
-33
lines changed

19 files changed

+413
-33
lines changed

app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,12 @@
1919
</ul>
2020
</div>
2121

22-
<script>
23-
require([
24-
"jquery",
25-
"Magento_Ui/js/modal/modal"
26-
], function($){
27-
if (this.modal) {
28-
this.modal.html($('[data-role="system_messages_list"]').html());
29-
} else {
30-
this.modal = $('[data-role="system_messages_list"]').modal({
31-
modalClass: 'modal-system-messages ui-popup-message',
32-
type: 'popup',
33-
buttons: []
34-
});
22+
<script type="text/x-magento-init">
23+
{
24+
"[data-role=system_messages_list]": {
25+
"Magento_AdminNotification/js/system/messages/popup": {
26+
"class":"modal-system-messages ui-popup-message"
27+
}
28+
}
3529
}
36-
this.modal.modal('openModal');
37-
});
3830
</script>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery',
8+
'Magento_Ui/js/modal/modal'
9+
], function ($, modal) {
10+
'use strict';
11+
12+
return function (data, element) {
13+
14+
if (modal.modal) {
15+
modal.modal.html($(element).html());
16+
} else {
17+
modal.modal = $(element).modal({
18+
modalClass: data.class,
19+
type: 'popup',
20+
buttons: []
21+
});
22+
}
23+
24+
modal.modal.modal('openModal');
25+
};
26+
});
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Captcha\Test\Unit\Observer;
7+
8+
use Magento\Captcha\Model\DefaultModel as CaptchaModel;
9+
use Magento\Captcha\Observer\CheckRegisterCheckoutObserver;
10+
use Magento\Captcha\Helper\Data as CaptchaDataHelper;
11+
use Magento\Framework\App\Action\Action;
12+
use Magento\Framework\App\ActionFlag;
13+
use Magento\Captcha\Observer\CaptchaStringResolver;
14+
use Magento\Checkout\Model\Type\Onepage;
15+
use Magento\Framework\App\Request\Http;
16+
use Magento\Framework\App\Response\Http as HttpResponse;
17+
use Magento\Framework\Event\Observer;
18+
use Magento\Framework\Json\Helper\Data as JsonHelper;
19+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
20+
use Magento\Quote\Model\Quote;
21+
22+
/**
23+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
24+
*/
25+
class CheckRegisterCheckoutObserverTest extends \PHPUnit_Framework_TestCase
26+
{
27+
const FORM_ID = 'register_during_checkout';
28+
29+
/**
30+
* @var CheckRegisterCheckoutObserver
31+
*/
32+
private $checkRegisterCheckoutObserver;
33+
34+
/**
35+
* @var ObjectManager
36+
*/
37+
private $objectManager;
38+
39+
/**
40+
* @var Observer
41+
*/
42+
private $observer;
43+
44+
/**
45+
* @var HttpResponse|\PHPUnit_Framework_MockObject_MockObject
46+
*/
47+
private $responseMock;
48+
49+
/**
50+
* @var HttpResponse|\PHPUnit_Framework_MockObject_MockObject
51+
*/
52+
private $requestMock;
53+
54+
/**
55+
* @var ActionFlag|\PHPUnit_Framework_MockObject_MockObject
56+
*/
57+
private $actionFlagMock;
58+
59+
/**
60+
* @var CaptchaStringResolver|\PHPUnit_Framework_MockObject_MockObject
61+
*/
62+
private $captchaStringResolverMock;
63+
64+
/**
65+
* @var JsonHelper|\PHPUnit_Framework_MockObject_MockObject
66+
*/
67+
private $jsonHelperMock;
68+
69+
/**
70+
* @var CaptchaModel|\PHPUnit_Framework_MockObject_MockObject
71+
*/
72+
private $captchaModelMock;
73+
74+
/**
75+
* @var Quote|\PHPUnit_Framework_MockObject_MockObject
76+
*/
77+
private $quoteModelMock;
78+
79+
/**
80+
* @var Action|\PHPUnit_Framework_MockObject_MockObject
81+
*/
82+
private $controllerMock;
83+
84+
protected function setUp()
85+
{
86+
$onepageModelTypeMock = $this->getMock(Onepage::class, [], [], '', false);
87+
$captchaHelperMock = $this->getMock(CaptchaDataHelper::class, [], [], '', false);
88+
$this->objectManager = new ObjectManager($this);
89+
$this->actionFlagMock = $this->getMock(ActionFlag::class, [], [], '', false);
90+
$this->captchaStringResolverMock = $this->getMock(CaptchaStringResolver::class, [], [], '', false);
91+
$this->captchaModelMock = $this->getMock(CaptchaModel::class, [], [], '', false);
92+
$this->quoteModelMock = $this->getMock(Quote::class, [], [], '', false);
93+
$this->controllerMock = $this->getMock(Action::class, [], [], '', false);
94+
$this->requestMock = $this->getMock(Http::class, [], [], '', false);
95+
$this->responseMock = $this->getMock(HttpResponse::class, [], [], '', false);
96+
$this->jsonHelperMock = $this->getMock(JsonHelper::class, [], [], '', false);
97+
$this->observer = new Observer(['controller_action' => $this->controllerMock]);
98+
99+
$this->checkRegisterCheckoutObserver = $this->objectManager->getObject(
100+
CheckRegisterCheckoutObserver::class,
101+
[
102+
'helper' => $captchaHelperMock,
103+
'actionFlag' => $this->actionFlagMock,
104+
'captchaStringResolver' => $this->captchaStringResolverMock,
105+
'typeOnepage' => $onepageModelTypeMock,
106+
'jsonHelper' => $this->jsonHelperMock
107+
]
108+
);
109+
110+
$captchaHelperMock->expects($this->once())
111+
->method('getCaptcha')
112+
->with(self::FORM_ID)
113+
->willReturn($this->captchaModelMock);
114+
$onepageModelTypeMock->expects($this->once())
115+
->method('getQuote')
116+
->willReturn($this->quoteModelMock);
117+
}
118+
119+
public function testCheckRegisterCheckoutForGuest()
120+
{
121+
$this->quoteModelMock->expects($this->once())
122+
->method('getCheckoutMethod')
123+
->willReturn(Onepage::METHOD_GUEST);
124+
$this->captchaModelMock->expects($this->never())
125+
->method('isRequired');
126+
127+
$this->checkRegisterCheckoutObserver->execute($this->observer);
128+
}
129+
130+
public function testCheckRegisterCheckoutWithNoCaptchaRequired()
131+
{
132+
$this->quoteModelMock->expects($this->once())
133+
->method('getCheckoutMethod')
134+
->willReturn(Onepage::METHOD_REGISTER);
135+
$this->captchaModelMock->expects($this->once())
136+
->method('isRequired')
137+
->willReturn(false);
138+
$this->captchaModelMock->expects($this->never())
139+
->method('isCorrect');
140+
141+
$this->checkRegisterCheckoutObserver->execute($this->observer);
142+
}
143+
144+
public function testCheckRegisterCheckoutWithIncorrectCaptcha()
145+
{
146+
$captchaValue = 'some_word';
147+
$encodedJsonValue = '{}';
148+
149+
$this->quoteModelMock->expects($this->once())
150+
->method('getCheckoutMethod')
151+
->willReturn(Onepage::METHOD_REGISTER);
152+
$this->captchaModelMock->expects($this->once())
153+
->method('isRequired')
154+
->willReturn(true);
155+
$this->controllerMock->expects($this->once())
156+
->method('getRequest')
157+
->willReturn($this->requestMock);
158+
$this->controllerMock->expects($this->once())
159+
->method('getResponse')
160+
->willReturn($this->responseMock);
161+
$this->controllerMock->expects($this->once())
162+
->method('getResponse')
163+
->willReturn($this->responseMock);
164+
$this->captchaStringResolverMock->expects($this->once())
165+
->method('resolve')
166+
->with($this->requestMock, self::FORM_ID)
167+
->willReturn($captchaValue);
168+
$this->captchaModelMock->expects($this->once())
169+
->method('isCorrect')
170+
->with($captchaValue)
171+
->willReturn(false);
172+
$this->actionFlagMock->expects($this->once())
173+
->method('set')
174+
->with('', Action::FLAG_NO_DISPATCH, true);
175+
$this->jsonHelperMock->expects($this->once())
176+
->method('jsonEncode')
177+
->willReturn($encodedJsonValue);
178+
$this->responseMock->expects($this->once())
179+
->method('representJson')
180+
->with($encodedJsonValue);
181+
182+
$this->checkRegisterCheckoutObserver->execute($this->observer);
183+
}
184+
185+
public function testCheckRegisterCheckoutWithCorrectCaptcha()
186+
{
187+
$this->quoteModelMock->expects($this->once())
188+
->method('getCheckoutMethod')
189+
->willReturn(Onepage::METHOD_REGISTER);
190+
$this->captchaModelMock->expects($this->once())
191+
->method('isRequired')
192+
->willReturn(true);
193+
$this->controllerMock->expects($this->once())
194+
->method('getRequest')
195+
->willReturn($this->requestMock);
196+
$this->captchaStringResolverMock->expects($this->once())
197+
->method('resolve')
198+
->with($this->requestMock, self::FORM_ID)
199+
->willReturn('some_word');
200+
$this->captchaModelMock->expects($this->once())
201+
->method('isCorrect')
202+
->with('some_word')
203+
->willReturn(true);
204+
$this->actionFlagMock->expects($this->never())
205+
->method('set');
206+
207+
$this->checkRegisterCheckoutObserver->execute($this->observer);
208+
}
209+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Magento\Catalog\Model\Product\Option;
1010

11+
use Magento\Catalog\Pricing\Price\BasePrice;
1112
use Magento\Framework\Model\AbstractModel;
1213
use Magento\Catalog\Model\Product;
1314
use Magento\Catalog\Model\Product\Option;
@@ -225,7 +226,7 @@ public function saveValues()
225226
public function getPrice($flag = false)
226227
{
227228
if ($flag && $this->getPriceType() == self::TYPE_PERCENT) {
228-
$basePrice = $this->getOption()->getProduct()->getFinalPrice();
229+
$basePrice = $this->getOption()->getProduct()->getPriceInfo()->getPrice(BasePrice::PRICE_CODE)->getValue();
229230
$price = $basePrice * ($this->_getData(self::KEY_PRICE) / 100);
230231
return $price;
231232
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,30 @@ private function getMockedOption()
170170
private function getMockedProduct()
171171
{
172172
$mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
173-
->setMethods(['getFinalPrice', '__wakeup'])
173+
->setMethods(['getPriceInfo', '__wakeup'])
174174
->disableOriginalConstructor();
175175
$mock = $mockBuilder->getMock();
176176

177177
$mock->expects($this->any())
178178
->method('getFinalPrice')
179179
->will($this->returnValue(10));
180+
$priceInfoMock = $this->getMockForAbstractClass(
181+
\Magento\Framework\Pricing\PriceInfoInterface::class,
182+
[],
183+
'',
184+
false,
185+
false,
186+
true,
187+
['getPrice']
188+
);
189+
190+
$priceMock = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Price\PriceInterface::class);
191+
192+
$priceInfoMock->expects($this->any())->method('getPrice')->willReturn($priceMock);
193+
194+
$mock->expects($this->any())->method('getPriceInfo')->willReturn($priceInfoMock);
195+
196+
$priceMock->expects($this->any())->method('getValue')->willReturn(10);
180197

181198
return $mock;
182199
}

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,12 @@ define([
276276
var element;
277277

278278
_.each(this.disabledAttributes, function (attribute) {
279-
registry.get('index = ' + attribute).disabled(false);
279+
registry.get('code = ' + attribute, 'index = ' + attribute).disabled(false);
280280
});
281281
this.disabledAttributes = [];
282282

283283
_.each(attributes, function (attribute) {
284-
element = registry.get('index = ' + attribute.code);
284+
element = registry.get('code = ' + attribute.code, 'index = ' + attribute.code);
285285
if (!_.isUndefined(element)) {
286286
element.disabled(true);
287287
this.disabledAttributes.push(attribute.code);

app/code/Magento/ImportExport/Model/Import/AbstractEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ public function validateData()
803803
if (!$this->isAttributeParticular($columnName)) {
804804
if (trim($columnName) == '') {
805805
$emptyHeaderColumns[] = $columnNumber;
806-
} elseif (!preg_match('/^[a-z][a-z0-9_]*$/', $columnName)) {
806+
} elseif (!preg_match('/^[a-z][\w]*$/u', $columnName)) {
807807
$invalidColumns[] = $columnName;
808808
} elseif ($this->needColumnCheck && !in_array($columnName, $this->getValidColumnNames())) {
809809
$invalidAttributes[] = $columnName;

app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ public function validateData()
769769
if (!$this->isAttributeParticular($columnName)) {
770770
if (trim($columnName) == '') {
771771
$emptyHeaderColumns[] = $columnNumber;
772-
} elseif (!preg_match('/^[a-z][a-z0-9_]*$/', $columnName)) {
772+
} elseif (!preg_match('/^[a-z][\w]*$/u', $columnName)) {
773773
$invalidColumns[] = $columnName;
774774
} elseif ($this->needColumnCheck && !in_array($columnName, $this->getValidColumnNames())) {
775775
$invalidAttributes[] = $columnName;

app/code/Magento/Newsletter/Controller/Subscriber/Confirm.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public function execute()
3232
}
3333
}
3434

35-
$this->getResponse()->setRedirect($this->_storeManager->getStore()->getBaseUrl());
35+
$resultRedirect = $this->resultRedirectFactory->create();
36+
$resultRedirect->setUrl($this->_storeManager->getStore()->getBaseUrl());
37+
return $resultRedirect;
3638
}
3739
}

app/code/Magento/Quote/Model/ResourceModel/Quote.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function getReservedOrderId($quote)
171171
{
172172
return $this->sequenceManager->getSequence(
173173
\Magento\Sales\Model\Order::ENTITY,
174-
$quote->getStore()->getGroup()->getDefaultStoreId()
174+
$quote->getStoreId()
175175
)
176176
->getNextValue();
177177
}
@@ -230,13 +230,24 @@ public function markQuotesRecollectOnCatalogRules()
230230
return $this;
231231
}
232232

233+
/**
234+
* @param \Magento\Catalog\Model\Product $product
235+
* @return Quote
236+
* @deprecated
237+
* @see subtractProductFromQuotes
238+
*/
239+
public function substractProductFromQuotes($product)
240+
{
241+
return $this->subtractProductFromQuotes($product);
242+
}
243+
233244
/**
234245
* Subtract product from all quotes quantities
235246
*
236247
* @param \Magento\Catalog\Model\Product $product
237248
* @return $this
238249
*/
239-
public function substractProductFromQuotes($product)
250+
public function subtractProductFromQuotes($product)
240251
{
241252
$productId = (int)$product->getId();
242253
if (!$productId) {

0 commit comments

Comments
 (0)