Skip to content

Commit 214d565

Browse files
author
olysenko
committed
Merge remote-tracking branch 'origin/2.2-develop' into MAGETWO-88217
2 parents 19824f2 + a328a6b commit 214d565

File tree

38 files changed

+329
-75
lines changed

38 files changed

+329
-75
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3349,7 +3349,7 @@ Tests:
33493349
* [#686](https://github.com/magento/magento2/issues/686) -- Product save validation errors in the admin don't hide the overlay
33503350
* [#702](https://github.com/magento/magento2/issues/702) -- Base table or view not found
33513351
* [#652](https://github.com/magento/magento2/issues/652) -- Multishipping checkout not to change the Billing address js issue
3352-
* [#648](https://github.com/magento/magento2/issues/648) -- An equal (=) sign in the hash of the product page to to break the tabs functionality
3352+
* [#648](https://github.com/magento/magento2/issues/648) -- An equal (=) sign in the hash of the product page to break the tabs functionality
33533353
* Service Contracts:
33543354
* Refactored usage of new API of the Customer module
33553355
* Implemented Service Contracts for the Sales module
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
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\Captcha\Test\Unit\Observer;
9+
10+
use Magento\Captcha\Model\DefaultModel as CaptchaModel;
11+
use Magento\Captcha\Observer\CheckRegisterCheckoutObserver;
12+
use Magento\Captcha\Helper\Data as CaptchaDataHelper;
13+
use Magento\Framework\App\Action\Action;
14+
use Magento\Framework\App\ActionFlag;
15+
use Magento\Captcha\Observer\CaptchaStringResolver;
16+
use Magento\Checkout\Model\Type\Onepage;
17+
use Magento\Framework\App\Request\Http;
18+
use Magento\Framework\App\Response\Http as HttpResponse;
19+
use Magento\Framework\Event\Observer;
20+
use Magento\Framework\Json\Helper\Data as JsonHelper;
21+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
22+
use Magento\Quote\Model\Quote;
23+
24+
/**
25+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26+
*/
27+
class CheckRegisterCheckoutObserverTest extends \PHPUnit\Framework\TestCase
28+
{
29+
const FORM_ID = 'register_during_checkout';
30+
31+
/**
32+
* @var CheckRegisterCheckoutObserver
33+
*/
34+
private $checkRegisterCheckoutObserver;
35+
36+
/**
37+
* @var ObjectManager
38+
*/
39+
private $objectManager;
40+
41+
/**
42+
* @var Observer
43+
*/
44+
private $observer;
45+
46+
/**
47+
* @var HttpResponse|\PHPUnit_Framework_MockObject_MockObject
48+
*/
49+
private $responseMock;
50+
51+
/**
52+
* @var HttpResponse|\PHPUnit_Framework_MockObject_MockObject
53+
*/
54+
private $requestMock;
55+
56+
/**
57+
* @var ActionFlag|\PHPUnit_Framework_MockObject_MockObject
58+
*/
59+
private $actionFlagMock;
60+
61+
/**
62+
* @var CaptchaStringResolver|\PHPUnit_Framework_MockObject_MockObject
63+
*/
64+
private $captchaStringResolverMock;
65+
66+
/**
67+
* @var JsonHelper|\PHPUnit_Framework_MockObject_MockObject
68+
*/
69+
private $jsonHelperMock;
70+
71+
/**
72+
* @var CaptchaModel|\PHPUnit_Framework_MockObject_MockObject
73+
*/
74+
private $captchaModelMock;
75+
76+
/**
77+
* @var Quote|\PHPUnit_Framework_MockObject_MockObject
78+
*/
79+
private $quoteModelMock;
80+
81+
/**
82+
* @var Action|\PHPUnit_Framework_MockObject_MockObject
83+
*/
84+
private $controllerMock;
85+
86+
protected function setUp()
87+
{
88+
$onepageModelTypeMock = $this->createMock(Onepage::class);
89+
$captchaHelperMock = $this->createMock(CaptchaDataHelper::class);
90+
$this->objectManager = new ObjectManager($this);
91+
$this->actionFlagMock = $this->createMock(ActionFlag::class);
92+
$this->captchaStringResolverMock = $this->createMock(CaptchaStringResolver::class);
93+
$this->captchaModelMock = $this->createMock(CaptchaModel::class);
94+
$this->quoteModelMock = $this->createMock(Quote::class);
95+
$this->controllerMock = $this->createMock(Action::class);
96+
$this->requestMock = $this->createMock(Http::class);
97+
$this->responseMock = $this->createMock(HttpResponse::class);
98+
$this->observer = new Observer(['controller_action' => $this->controllerMock]);
99+
$this->jsonHelperMock = $this->createMock(JsonHelper::class);
100+
101+
$this->checkRegisterCheckoutObserver = $this->objectManager->getObject(
102+
CheckRegisterCheckoutObserver::class,
103+
[
104+
'helper' => $captchaHelperMock,
105+
'actionFlag' => $this->actionFlagMock,
106+
'captchaStringResolver' => $this->captchaStringResolverMock,
107+
'typeOnepage' => $onepageModelTypeMock,
108+
'jsonHelper' => $this->jsonHelperMock
109+
]
110+
);
111+
112+
$captchaHelperMock->expects($this->once())
113+
->method('getCaptcha')
114+
->with(self::FORM_ID)
115+
->willReturn($this->captchaModelMock);
116+
$onepageModelTypeMock->expects($this->once())
117+
->method('getQuote')
118+
->willReturn($this->quoteModelMock);
119+
}
120+
121+
public function testCheckRegisterCheckoutForGuest()
122+
{
123+
$this->quoteModelMock->expects($this->once())
124+
->method('getCheckoutMethod')
125+
->willReturn(Onepage::METHOD_GUEST);
126+
$this->captchaModelMock->expects($this->never())
127+
->method('isRequired');
128+
129+
$this->checkRegisterCheckoutObserver->execute($this->observer);
130+
}
131+
132+
public function testCheckRegisterCheckoutWithNoCaptchaRequired()
133+
{
134+
$this->quoteModelMock->expects($this->once())
135+
->method('getCheckoutMethod')
136+
->willReturn(Onepage::METHOD_REGISTER);
137+
$this->captchaModelMock->expects($this->once())
138+
->method('isRequired')
139+
->willReturn(false);
140+
$this->captchaModelMock->expects($this->never())
141+
->method('isCorrect');
142+
143+
$this->checkRegisterCheckoutObserver->execute($this->observer);
144+
}
145+
146+
public function testCheckRegisterCheckoutWithIncorrectCaptcha()
147+
{
148+
$captchaValue = 'some_word';
149+
$encodedJsonValue = '{}';
150+
151+
$this->quoteModelMock->expects($this->once())
152+
->method('getCheckoutMethod')
153+
->willReturn(Onepage::METHOD_REGISTER);
154+
$this->captchaModelMock->expects($this->once())
155+
->method('isRequired')
156+
->willReturn(true);
157+
$this->controllerMock->expects($this->once())
158+
->method('getRequest')
159+
->willReturn($this->requestMock);
160+
$this->controllerMock->expects($this->once())
161+
->method('getResponse')
162+
->willReturn($this->responseMock);
163+
$this->controllerMock->expects($this->once())
164+
->method('getResponse')
165+
->willReturn($this->responseMock);
166+
$this->captchaStringResolverMock->expects($this->once())
167+
->method('resolve')
168+
->with($this->requestMock, self::FORM_ID)
169+
->willReturn($captchaValue);
170+
$this->captchaModelMock->expects($this->once())
171+
->method('isCorrect')
172+
->with($captchaValue)
173+
->willReturn(false);
174+
$this->actionFlagMock->expects($this->once())
175+
->method('set')
176+
->with('', Action::FLAG_NO_DISPATCH, true);
177+
$this->jsonHelperMock->expects($this->once())
178+
->method('jsonEncode')
179+
->willReturn($encodedJsonValue);
180+
$this->responseMock->expects($this->once())
181+
->method('representJson')
182+
->with($encodedJsonValue);
183+
184+
$this->checkRegisterCheckoutObserver->execute($this->observer);
185+
}
186+
187+
public function testCheckRegisterCheckoutWithCorrectCaptcha()
188+
{
189+
$this->quoteModelMock->expects($this->once())
190+
->method('getCheckoutMethod')
191+
->willReturn(Onepage::METHOD_REGISTER);
192+
$this->captchaModelMock->expects($this->once())
193+
->method('isRequired')
194+
->willReturn(true);
195+
$this->controllerMock->expects($this->once())
196+
->method('getRequest')
197+
->willReturn($this->requestMock);
198+
$this->captchaStringResolverMock->expects($this->once())
199+
->method('resolve')
200+
->with($this->requestMock, self::FORM_ID)
201+
->willReturn('some_word');
202+
$this->captchaModelMock->expects($this->once())
203+
->method('isCorrect')
204+
->with('some_word')
205+
->willReturn(true);
206+
$this->actionFlagMock->expects($this->never())
207+
->method('set');
208+
209+
$this->checkRegisterCheckoutObserver->execute($this->observer);
210+
}
211+
}

app/code/Magento/Catalog/etc/adminhtml/menu.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<add id="Magento_Catalog::catalog_categories" title="Categories" translate="title" module="Magento_Catalog" sortOrder="20" parent="Magento_Catalog::inventory" action="catalog/category/" resource="Magento_Catalog::categories"/>
1313
<add id="Magento_Catalog::catalog_attributes_attributes" title="Product" translate="title" module="Magento_Catalog" sortOrder="30" parent="Magento_Backend::stores_attributes" action="catalog/product_attribute/" resource="Magento_Catalog::attributes_attributes"/>
1414
<add id="Magento_Catalog::catalog_attributes_sets" title="Attribute Set" translate="title" module="Magento_Catalog" sortOrder="40" parent="Magento_Backend::stores_attributes" action="catalog/product_set/" resource="Magento_Catalog::sets"/>
15-
1615
<add id="Magento_Catalog::inventory" title="Inventory" translate="title" module="Magento_Catalog" sortOrder="10" parent="Magento_Catalog::catalog" dependsOnModule="Magento_Catalog" resource="Magento_Catalog::catalog"/>
1716
</menu>
1817
</config>

app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Widget/CategoriesJson.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(Context $context, Registry $coreRegistry)
3232
/**
3333
* Initialize category object in registry
3434
*
35-
* @return Category
35+
* @return Category|bool
3636
*/
3737
protected function _initCategory()
3838
{

app/code/Magento/CatalogSearch/Model/ResourceModel/Engine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function processAttributeValue($attribute, $value)
120120
*
121121
* @param array $index
122122
* @param string $separator
123-
* @return string
123+
* @return array
124124
*/
125125
public function prepareEntityIndex($index, $separator = ' ')
126126
{

app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,9 @@ protected function orderCountryOptions(array $countryOptions)
394394
]];
395395
foreach ($countryOptions as $countryOption) {
396396
if (empty($countryOption['value']) || in_array($countryOption['value'], $this->topCountryCodes)) {
397-
array_push($headOptions, $countryOption);
397+
$headOptions[] = $countryOption;
398398
} else {
399-
array_push($tailOptions, $countryOption);
399+
$tailOptions[] = $countryOption;
400400
}
401401
}
402402
return array_merge($headOptions, $tailOptions);

app/code/Magento/Checkout/Block/Checkout/DirectoryDataProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ private function orderCountryOptions(array $countryOptions)
141141
]];
142142
foreach ($countryOptions as $countryOption) {
143143
if (empty($countryOption['value']) || in_array($countryOption['value'], $topCountryCodes)) {
144-
array_push($headOptions, $countryOption);
144+
$headOptions[] = $countryOption;
145145
} else {
146-
array_push($tailOptions, $countryOption);
146+
$tailOptions[] = $countryOption;
147147
}
148148
}
149149
return array_merge($headOptions, $tailOptions);

app/code/Magento/Customer/Block/Widget/Dob.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ protected function getFormFilter()
127127
protected function applyOutputFilter($value)
128128
{
129129
$filter = $this->getFormFilter();
130-
if ($filter) {
130+
if ($filter && $value) {
131+
$value = date('Y-m-d', $this->getTime());
131132
$value = $filter->outputFilter($value);
132133
}
133134
return $value;

app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ define([
3131
this.options.cache.label = $(this.options.passwordStrengthMeterLabelSelector, this.element);
3232

3333
// We need to look outside the module for backward compatibility, since someone can already use the module.
34-
// @todo Narrow this selector in 2.3 so it doesn't accidentally finds the the email field from the
34+
// @todo Narrow this selector in 2.3 so it doesn't accidentally finds the email field from the
3535
// newsletter email field or any other "email" field.
3636
this.options.cache.email = $(this.options.formSelector).find(this.options.emailSelector);
3737
this._bind();

app/code/Magento/Deploy/Package/Processor/PreProcessor/Less.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private function buildMap($filePath, $packagePath, $contentType)
188188
if (!isset($this->map[$filePath])) {
189189
$this->map[$filePath] = [];
190190
}
191-
array_push($this->map[$filePath], $resolvedMapPath);
191+
$this->map[$filePath][] = $resolvedMapPath;
192192
$this->buildMap($resolvedMapPath, $packagePath, $contentType);
193193
};
194194
if ($content) {

app/code/Magento/ImportExport/Model/Report/Csv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function createReport(
7777
$outputCsv = $this->createOutputCsvModel($outputFileName);
7878

7979
$columnsName = $sourceCsv->getColNames();
80-
array_push($columnsName, self::REPORT_ERROR_COLUMN_NAME);
80+
$columnsName[] = self::REPORT_ERROR_COLUMN_NAME;
8181
$outputCsv->setHeaderCols($columnsName);
8282

8383
foreach ($sourceCsv as $rowNum => $rowData) {

app/code/Magento/Integration/view/adminhtml/web/js/integration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ define([
200200
if (IdentityLogin.win.closed ||
201201
IdentityLogin.win.location.href == IdentityLogin.successCallbackUrl //eslint-disable-line eqeqeq
202202
) {
203-
//Stop the the polling
203+
//Stop the polling
204204
clearInterval(IdentityLogin.checker);
205205
$('body').trigger('processStart');
206206
//Check for window closed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,7 @@ public function getErrors()
20222022
foreach ($this->getMessages() as $message) {
20232023
/* @var $error \Magento\Framework\Message\AbstractMessage */
20242024
if ($message->getType() == \Magento\Framework\Message\MessageInterface::TYPE_ERROR) {
2025-
array_push($errors, $message);
2025+
$errors[] = $message;
20262026
}
20272027
}
20282028
return $errors;

app/code/Magento/Sales/view/adminhtml/templates/items/column/name.phtml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,36 @@
1414
?>
1515

1616
<?php if ($_item = $block->getItem()): ?>
17-
<div id="order_item_<?= /* @escapeNotVerified */ $_item->getId() ?>_title"
17+
<div id="order_item_<?= $block->escapeHtml($_item->getId()) ?>_title"
1818
class="product-title">
1919
<?= $block->escapeHtml($_item->getName()) ?>
2020
</div>
21-
2221
<div class="product-sku-block">
23-
<span><?= /* @escapeNotVerified */ __('SKU') ?>:</span> <?= implode('<br />', $this->helper('Magento\Catalog\Helper\Data')->splitSku($block->escapeHtml($block->getSku()))) ?>
22+
<span><?= $block->escapeHtml(__('SKU'))?>:</span> <?= implode('<br />', $this->helper('Magento\Catalog\Helper\Data')->splitSku($block->escapeHtml($block->getSku()))) ?>
2423
</div>
2524

2625
<?php if ($block->getOrderOptions()): ?>
2726
<dl class="item-options">
2827
<?php foreach ($block->getOrderOptions() as $_option): ?>
29-
<dt><?= /* @escapeNotVerified */ $_option['label'] ?>:</dt>
28+
<dt><?= $block->escapeHtml($_option['label']) ?>:</dt>
3029
<dd>
3130
<?php if (isset($_option['custom_view']) && $_option['custom_view']): ?>
32-
<?= /* @escapeNotVerified */ $block->getCustomizedOptionValue($_option) ?>
31+
<?= $block->escapeHtml($block->getCustomizedOptionValue($_option)) ?>
3332
<?php else: ?>
3433
<?php $_option = $block->getFormattedOption($_option['value']); ?>
35-
<?= /* @escapeNotVerified */ $_option['value'] ?><?php if (isset($_option['remainder']) && $_option['remainder']): ?><span id="<?= /* @escapeNotVerified */ $_dots = 'dots' . uniqid() ?>"> ...</span><span id="<?= /* @escapeNotVerified */ $_id = 'id' . uniqid() ?>"><?= /* @escapeNotVerified */ $_option['remainder'] ?></span>
34+
<?= $block->escapeHtml($_option['value']) ?>
35+
<?php if (isset($_option['remainder']) && $_option['remainder']): ?>
36+
<?php $dots = 'dots' . uniqid(); ?>
37+
<span id="<?= /* @noEscape */ $dots; ?>"> ...</span>
38+
<?php $id = 'id' . uniqid(); ?>
39+
<span id="<?= /* @noEscape */ $id; ?>"><?= $block->escapeHtml($_option['remainder']) ?></span>
3640
<script>
37-
require(['prototype'], function() {
38-
$('<?= /* @escapeNotVerified */ $_id ?>').hide();
39-
$('<?= /* @escapeNotVerified */ $_id ?>').up().observe('mouseover', function(){$('<?= /* @escapeNotVerified */ $_id ?>').show();});
40-
$('<?= /* @escapeNotVerified */ $_id ?>').up().observe('mouseover', function(){$('<?= /* @escapeNotVerified */ $_dots ?>').hide();});
41-
$('<?= /* @escapeNotVerified */ $_id ?>').up().observe('mouseout', function(){$('<?= /* @escapeNotVerified */ $_id ?>').hide();});
42-
$('<?= /* @escapeNotVerified */ $_id ?>').up().observe('mouseout', function(){$('<?= /* @escapeNotVerified */ $_dots ?>').show();});
41+
require(['prototype'], function(){
42+
$('<?= /* @noEscape */ $id; ?>').hide();
43+
$('<?= /* @noEscape */ $id; ?>').up().observe('mouseover', function(){$('<?= /* @noEscape */ $id; ?>').show();});
44+
$('<?= /* @noEscape */ $id; ?>').up().observe('mouseover', function(){$('<?= /* @noEscape */ $dots; ?>').hide();});
45+
$('<?= /* @noEscape */ $id; ?>').up().observe('mouseout', function(){$('<?= /* @noEscape */ $id; ?>').hide();});
46+
$('<?= /* @noEscape */ $id; ?>').up().observe('mouseout', function(){$('<?= /* @noEscape */ $dots; ?>').show();});
4347
});
4448
</script>
4549
<?php endif; ?>

0 commit comments

Comments
 (0)