Skip to content

Commit 009ee45

Browse files
author
ybohaienko
committed
Merge branch '2.1.15-develop' into MAGETWO-92196
2 parents 62638a3 + 60b24eb commit 009ee45

File tree

88 files changed

+947
-752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+947
-752
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+
});

app/code/Magento/Backend/view/adminhtml/templates/system/search.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<% if (data.items.length) { %>
4343
<% _.each(data.items, function(value){ %>
4444
<li class="item"
45-
<%- data.optionData(value) %>
45+
<%= data.optionData(value) %>
4646
>
4747
<a href="<%- value.url %>" class="title"><%- value.name %></a>
4848
<span class="type"><%- value.type %></span>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Captcha\Test\Unit\Observer;
8+
9+
use Magento\Captcha\Helper\Data as CaptchaDataHelper;
10+
use Magento\Captcha\Observer\CaptchaStringResolver;
11+
use Magento\Framework\App\Request\Http as HttpRequest;
12+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
13+
14+
class CaptchaStringResolverTest extends \PHPUnit_Framework_TestCase
15+
{
16+
/**
17+
* @var ObjectManager
18+
*/
19+
private $objectManagerHelper;
20+
21+
/**
22+
* @var CaptchaStringResolver
23+
*/
24+
private $captchaStringResolver;
25+
26+
/**
27+
* @var HttpRequest|\PHPUnit_Framework_MockObject_MockObject
28+
*/
29+
private $requestMock;
30+
31+
protected function setUp()
32+
{
33+
$this->objectManagerHelper = new ObjectManager($this);
34+
$this->requestMock = $this->getMock(HttpRequest::class, [], [], '', false);
35+
$this->captchaStringResolver = $this->objectManagerHelper->getObject(CaptchaStringResolver::class);
36+
}
37+
38+
public function testResolveWithFormIdSet()
39+
{
40+
$formId = 'contact_us';
41+
$captchaValue = 'some-value';
42+
43+
$this->requestMock->expects($this->once())
44+
->method('getPost')
45+
->with(CaptchaDataHelper::INPUT_NAME_FIELD_VALUE)
46+
->willReturn([$formId => $captchaValue]);
47+
48+
self::assertEquals(
49+
$this->captchaStringResolver->resolve($this->requestMock, $formId),
50+
$captchaValue
51+
);
52+
}
53+
54+
public function testResolveWithNoFormIdInRequest()
55+
{
56+
$formId = 'contact_us';
57+
58+
$this->requestMock->expects($this->once())
59+
->method('getPost')
60+
->with(CaptchaDataHelper::INPUT_NAME_FIELD_VALUE)
61+
->willReturn([]);
62+
63+
self::assertEquals(
64+
$this->captchaStringResolver->resolve($this->requestMock, $formId),
65+
''
66+
);
67+
}
68+
}
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/Block/Adminhtml/Category/Tree.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public function getBreadcrumbsJavascript($path, $javascriptVarName)
325325
*
326326
* @param Node|array $node
327327
* @param int $level
328-
* @return string
328+
* @return array
329329
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
330330
* @SuppressWarnings(PHPMD.NPathComplexity)
331331
*/

app/code/Magento/Catalog/Block/Adminhtml/Category/Widget/Chooser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function (node, e) {
144144
*
145145
* @param \Magento\Framework\Data\Tree\Node|array $node
146146
* @param int $level
147-
* @return string
147+
* @return array
148148
*/
149149
protected function _getNodeJson($node, $level = 0)
150150
{

app/code/Magento/Catalog/Block/Adminhtml/Form/Renderer/Fieldset/Element.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Element extends \Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Eleme
2121
/**
2222
* Retrieve data object related with form
2323
*
24-
* @return \Magento\Catalog\Model\Product || \Magento\Catalog\Model\Category
24+
* @return \Magento\Catalog\Model\Product|\Magento\Catalog\Model\Category
2525
*/
2626
public function getDataObject()
2727
{

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Grid.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ protected function _prepareColumns()
101101
'type' => 'options',
102102
'options' => ['1' => __('Yes'), '0' => __('No')],
103103
'align' => 'center'
104-
],
105-
'is_user_defined'
104+
]
106105
);
107106

108107
$this->_eventManager->dispatch('product_attribute_grid_build', ['grid' => $this]);

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Search.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function getSelectorOptions()
8181
*
8282
* @param string $labelPart
8383
* @param int $templateId
84-
* @return \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection
84+
* @return array
8585
*/
8686
public function getSuggestedAttributes($labelPart, $templateId = null)
8787
{

0 commit comments

Comments
 (0)