Skip to content

Commit ee11eb6

Browse files
🔃 [EngCom] Public Pull Requests - 2.3-develop
Accepted Public Pull Requests: - #19143: Allow to read HTTP/2 response header in curl client. (by @vovayatsyuk) - #19144: [2.3-develop] [Forwardport Unit test] #17833:  Child theme does not inherit translations fr� (by @vpodorozh) - #19130: [Quote] API: Fixed issue "Can not update cart with a reserved order number like 000000651" (by @vasilii-b) - magento-engcom/import-export-improvements#143: Fixed miss called property in getStoreIdByCode method (by @maxalmonte14) - #18906: Add missing unit test for WishlistSettings plugin (by @dmytro-ch) - #18565: [Forwardport] Fix type hint of customer-data updateSectionId parameters (by @gelanivishal) Fixed GitHub Issues: - #19127: Cannot connect to Magento 2 market place (reported by @terrybakshi) has been fixed in #19143 by @vovayatsyuk in 2.3-develop branch Related commits: 1. e827b32 - #17833: Child theme does not inherit translations from parent theme (reported by @rossmc) has been fixed in #19144 by @vpodorozh in 2.3-develop branch Related commits: 1. 57fcc1b 2. fe73cf0 - #19101: API REST and Reserved Order Id (reported by @davidlhoumaud) has been fixed in #19130 by @vasilii-b in 2.3-develop branch Related commits: 1. fe7b9ac
2 parents 1536c15 + 539370e commit ee11eb6

File tree

21 files changed

+925
-108
lines changed

21 files changed

+925
-108
lines changed

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
/**
2222
* Class Bundle
23+
*
2324
* @package Magento\BundleImportExport\Model\Import\Product\Type
2425
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
2526
*/
@@ -349,6 +350,8 @@ protected function populateSelectionTemplate($selection, $optionId, $parentId, $
349350
}
350351

351352
/**
353+
* Deprecated method for retrieving mapping between skus and products.
354+
*
352355
* @deprecated Misspelled method
353356
* @see retrieveProductsByCachedSkus
354357
*/
@@ -600,6 +603,7 @@ protected function insertOptions()
600603

601604
/**
602605
* Populate array for insert option values
606+
*
603607
* @param array $optionIds
604608
* @return array
605609
*/
@@ -779,7 +783,7 @@ protected function clear()
779783
*/
780784
private function getStoreIdByCode(string $storeCode): int
781785
{
782-
if (!isset($this->storeIdToCode[$storeCode])) {
786+
if (!isset($this->storeCodeToId[$storeCode])) {
783787
/** @var $store \Magento\Store\Model\Store */
784788
foreach ($this->storeManager->getStores() as $store) {
785789
$this->storeCodeToId[$store->getCode()] = $store->getId();
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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\Helper\Data;
11+
use Magento\Captcha\Model\DefaultModel;
12+
use Magento\Captcha\Observer\CaptchaStringResolver;
13+
use Magento\Captcha\Observer\CheckUserLoginBackendObserver;
14+
use Magento\Framework\App\RequestInterface;
15+
use Magento\Framework\Event;
16+
use Magento\Framework\Event\Observer;
17+
use Magento\Framework\Message\ManagerInterface;
18+
use PHPUnit\Framework\TestCase;
19+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
20+
21+
/**
22+
* Class CheckUserLoginBackendObserverTest
23+
*/
24+
class CheckUserLoginBackendObserverTest extends TestCase
25+
{
26+
/**
27+
* @var CheckUserLoginBackendObserver
28+
*/
29+
private $observer;
30+
31+
/**
32+
* @var ManagerInterface|MockObject
33+
*/
34+
private $messageManagerMock;
35+
36+
/**
37+
* @var CaptchaStringResolver|MockObject
38+
*/
39+
private $captchaStringResolverMock;
40+
41+
/**
42+
* @var RequestInterface|MockObject
43+
*/
44+
private $requestMock;
45+
46+
/**
47+
* @var Data|MockObject
48+
*/
49+
private $helperMock;
50+
51+
/**
52+
* Set Up
53+
*
54+
* @return void
55+
*/
56+
protected function setUp()
57+
{
58+
$this->helperMock = $this->createMock(Data::class);
59+
$this->messageManagerMock = $this->createMock(ManagerInterface::class);
60+
$this->captchaStringResolverMock = $this->createMock(CaptchaStringResolver::class);
61+
$this->requestMock = $this->createMock(RequestInterface::class);
62+
63+
$this->observer = new CheckUserLoginBackendObserver(
64+
$this->helperMock,
65+
$this->captchaStringResolverMock,
66+
$this->requestMock
67+
);
68+
}
69+
70+
/**
71+
* Test check user login in backend with correct captcha
72+
*
73+
* @dataProvider requiredCaptchaDataProvider
74+
* @param bool $isRequired
75+
* @return void
76+
*/
77+
public function testCheckOnBackendLoginWithCorrectCaptcha(bool $isRequired): void
78+
{
79+
$formId = 'backend_login';
80+
$login = 'admin';
81+
$captchaValue = 'captcha-value';
82+
83+
/** @var Observer|MockObject $observerMock */
84+
$observerMock = $this->createPartialMock(Observer::class, ['getEvent']);
85+
$eventMock = $this->createPartialMock(Event::class, ['getUsername']);
86+
$captcha = $this->createMock(DefaultModel::class);
87+
88+
$eventMock->method('getUsername')->willReturn('admin');
89+
$observerMock->method('getEvent')->willReturn($eventMock);
90+
$captcha->method('isRequired')->with($login)->willReturn($isRequired);
91+
$captcha->method('isCorrect')->with($captchaValue)->willReturn(true);
92+
$this->helperMock->method('getCaptcha')->with($formId)->willReturn($captcha);
93+
$this->captchaStringResolverMock->method('resolve')->with($this->requestMock, $formId)
94+
->willReturn($captchaValue);
95+
96+
$this->observer->execute($observerMock);
97+
}
98+
99+
/**
100+
* @return array
101+
*/
102+
public function requiredCaptchaDataProvider(): array
103+
{
104+
return [
105+
[true],
106+
[false]
107+
];
108+
}
109+
110+
/**
111+
* Test check user login in backend with wrong captcha
112+
*
113+
* @return void
114+
* @expectedException \Magento\Framework\Exception\Plugin\AuthenticationException
115+
*/
116+
public function testCheckOnBackendLoginWithWrongCaptcha(): void
117+
{
118+
$formId = 'backend_login';
119+
$login = 'admin';
120+
$captchaValue = 'captcha-value';
121+
122+
/** @var Observer|MockObject $observerMock */
123+
$observerMock = $this->createPartialMock(Observer::class, ['getEvent']);
124+
$eventMock = $this->createPartialMock(Event::class, ['getUsername']);
125+
$captcha = $this->createMock(DefaultModel::class);
126+
127+
$eventMock->method('getUsername')->willReturn($login);
128+
$observerMock->method('getEvent')->willReturn($eventMock);
129+
$captcha->method('isRequired')->with($login)->willReturn(true);
130+
$captcha->method('isCorrect')->with($captchaValue)->willReturn(false);
131+
$this->helperMock->method('getCaptcha')->with($formId)->willReturn($captcha);
132+
$this->captchaStringResolverMock->method('resolve')->with($this->requestMock, $formId)
133+
->willReturn($captchaValue);
134+
135+
$this->observer->execute($observerMock);
136+
}
137+
}

app/code/Magento/Customer/Controller/Section/Load.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function __construct(
5959
}
6060

6161
/**
62-
* @return \Magento\Framework\Controller\Result\Json
62+
* @inheritdoc
6363
*/
6464
public function execute()
6565
{
@@ -71,11 +71,11 @@ public function execute()
7171
$sectionNames = $this->getRequest()->getParam('sections');
7272
$sectionNames = $sectionNames ? array_unique(\explode(',', $sectionNames)) : null;
7373

74-
$updateSectionId = $this->getRequest()->getParam('update_section_id');
75-
if ('false' === $updateSectionId) {
76-
$updateSectionId = false;
74+
$forceNewSectionTimestamp = $this->getRequest()->getParam('force_new_section_timestamp');
75+
if ('false' === $forceNewSectionTimestamp) {
76+
$forceNewSectionTimestamp = false;
7777
}
78-
$response = $this->sectionPool->getSectionsData($sectionNames, (bool)$updateSectionId);
78+
$response = $this->sectionPool->getSectionsData($sectionNames, (bool)$forceNewSectionTimestamp);
7979
} catch (\Exception $e) {
8080
$resultJson->setStatusHeader(
8181
\Zend\Http\Response::STATUS_CODE_400,

app/code/Magento/Customer/CustomerData/Section/Identifier.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ public function __construct(
4343
/**
4444
* Init mark(identifier) for sections
4545
*
46-
* @param bool $forceUpdate
46+
* @param bool $forceNewTimestamp
4747
* @return int
4848
*/
49-
public function initMark($forceUpdate)
49+
public function initMark($forceNewTimestamp)
5050
{
51-
if ($forceUpdate) {
51+
if ($forceNewTimestamp) {
5252
$this->markId = time();
5353
return $this->markId;
5454
}
@@ -67,19 +67,19 @@ public function initMark($forceUpdate)
6767
* Mark sections with data id
6868
*
6969
* @param array $sectionsData
70-
* @param null $sectionNames
71-
* @param bool $updateIds
70+
* @param array|null $sectionNames
71+
* @param bool $forceNewTimestamp
7272
* @return array
7373
*/
74-
public function markSections(array $sectionsData, $sectionNames = null, $updateIds = false)
74+
public function markSections(array $sectionsData, $sectionNames = null, $forceNewTimestamp = false)
7575
{
7676
if (!$sectionNames) {
7777
$sectionNames = array_keys($sectionsData);
7878
}
79-
$markId = $this->initMark($updateIds);
79+
$markId = $this->initMark($forceNewTimestamp);
8080

8181
foreach ($sectionNames as $name) {
82-
if ($updateIds || !array_key_exists(self::SECTION_KEY, $sectionsData[$name])) {
82+
if ($forceNewTimestamp || !array_key_exists(self::SECTION_KEY, $sectionsData[$name])) {
8383
$sectionsData[$name][self::SECTION_KEY] = $markId;
8484
}
8585
}

app/code/Magento/Customer/CustomerData/SectionPool.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ public function __construct(
5353
}
5454

5555
/**
56-
* {@inheritdoc}
56+
* @inheritdoc
5757
*/
58-
public function getSectionsData(array $sectionNames = null, $updateIds = false)
58+
public function getSectionsData(array $sectionNames = null, $forceNewTimestamp = false)
5959
{
6060
$sectionsData = $sectionNames ? $this->getSectionDataByNames($sectionNames) : $this->getAllSectionData();
61-
$sectionsData = $this->identifier->markSections($sectionsData, $sectionNames, $updateIds);
61+
$sectionsData = $this->identifier->markSections($sectionsData, $sectionNames, $forceNewTimestamp);
6262
return $sectionsData;
6363
}
6464

app/code/Magento/Customer/CustomerData/SectionPoolInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ interface SectionPoolInterface
1414
* Get section data by section names. If $sectionNames is null then return all sections data
1515
*
1616
* @param array $sectionNames
17-
* @param bool $updateIds
17+
* @param bool $forceNewTimestamp
1818
* @return array
1919
*/
20-
public function getSectionsData(array $sectionNames = null, $updateIds = false);
20+
public function getSectionsData(array $sectionNames = null, $forceNewTimestamp = false);
2121
}

app/code/Magento/Customer/Test/Unit/Controller/Section/LoadTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ protected function setUp()
8383
}
8484

8585
/**
86-
* @param $sectionNames
87-
* @param $updateSectionID
88-
* @param $sectionNamesAsArray
89-
* @param $updateIds
86+
* @param string $sectionNames
87+
* @param bool $forceNewSectionTimestamp
88+
* @param string[] $sectionNamesAsArray
89+
* @param bool $forceNewTimestamp
9090
* @dataProvider executeDataProvider
9191
*/
92-
public function testExecute($sectionNames, $updateSectionID, $sectionNamesAsArray, $updateIds)
92+
public function testExecute($sectionNames, $forceNewSectionTimestamp, $sectionNamesAsArray, $forceNewTimestamp)
9393
{
9494
$this->resultJsonFactoryMock->expects($this->once())
9595
->method('create')
@@ -103,12 +103,12 @@ public function testExecute($sectionNames, $updateSectionID, $sectionNamesAsArra
103103

104104
$this->httpRequestMock->expects($this->exactly(2))
105105
->method('getParam')
106-
->withConsecutive(['sections'], ['update_section_id'])
107-
->willReturnOnConsecutiveCalls($sectionNames, $updateSectionID);
106+
->withConsecutive(['sections'], ['force_new_section_timestamp'])
107+
->willReturnOnConsecutiveCalls($sectionNames, $forceNewSectionTimestamp);
108108

109109
$this->sectionPoolMock->expects($this->once())
110110
->method('getSectionsData')
111-
->with($sectionNamesAsArray, $updateIds)
111+
->with($sectionNamesAsArray, $forceNewTimestamp)
112112
->willReturn([
113113
'message' => 'some message',
114114
'someKey' => 'someValue'
@@ -133,15 +133,15 @@ public function executeDataProvider()
133133
return [
134134
[
135135
'sectionNames' => 'sectionName1,sectionName2,sectionName3',
136-
'updateSectionID' => 'updateSectionID',
136+
'forceNewSectionTimestamp' => 'forceNewSectionTimestamp',
137137
'sectionNamesAsArray' => ['sectionName1', 'sectionName2', 'sectionName3'],
138-
'updateIds' => true
138+
'forceNewTimestamp' => true
139139
],
140140
[
141141
'sectionNames' => null,
142-
'updateSectionID' => null,
142+
'forceNewSectionTimestamp' => null,
143143
'sectionNamesAsArray' => null,
144-
'updateIds' => false
144+
'forceNewTimestamp' => false
145145
],
146146
];
147147
}

app/code/Magento/Customer/Test/Unit/CustomerData/SectionPoolTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testGetSectionsDataAllSections()
6363

6464
$this->identifierMock->expects($this->once())
6565
->method('markSections')
66-
//check also default value for $updateIds = false
66+
//check also default value for $forceTimestamp = false
6767
->with($allSectionsData, $sectionNames, false)
6868
->willReturn($identifierResult);
6969
$modelResult = $this->model->getSectionsData($sectionNames);

app/code/Magento/Customer/view/frontend/web/js/customer-data.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,17 @@ define([
7575

7676
/**
7777
* @param {Object} sectionNames
78-
* @param {Number} updateSectionId
78+
* @param {Boolean} forceNewSectionTimestamp
7979
* @return {*}
8080
*/
81-
getFromServer: function (sectionNames, updateSectionId) {
81+
getFromServer: function (sectionNames, forceNewSectionTimestamp) {
8282
var parameters;
8383

8484
sectionNames = sectionConfig.filterClientSideSections(sectionNames);
8585
parameters = _.isArray(sectionNames) ? {
8686
sections: sectionNames.join(',')
8787
} : [];
88-
parameters['update_section_id'] = updateSectionId;
88+
parameters['force_new_section_timestamp'] = forceNewSectionTimestamp;
8989

9090
return $.getJSON(options.sectionLoadUrl, parameters).fail(function (jqXHR) {
9191
throw new Error(jqXHR);
@@ -326,11 +326,11 @@ define([
326326

327327
/**
328328
* @param {Array} sectionNames
329-
* @param {Number} updateSectionId
329+
* @param {Boolean} forceNewSectionTimestamp
330330
* @return {*}
331331
*/
332-
reload: function (sectionNames, updateSectionId) {
333-
return dataProvider.getFromServer(sectionNames, updateSectionId).done(function (sections) {
332+
reload: function (sectionNames, forceNewSectionTimestamp) {
333+
return dataProvider.getFromServer(sectionNames, forceNewSectionTimestamp).done(function (sections) {
334334
$(document).trigger('customer-data-reload', [sectionNames]);
335335
buffer.update(sections);
336336
});

app/code/Magento/Quote/Api/Data/CartInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,14 @@ public function setBillingAddress(\Magento\Quote\Api\Data\AddressInterface $bill
223223
/**
224224
* Returns the reserved order ID for the cart.
225225
*
226-
* @return int|null Reserved order ID. Otherwise, null.
226+
* @return string|null Reserved order ID. Otherwise, null.
227227
*/
228228
public function getReservedOrderId();
229229

230230
/**
231231
* Sets the reserved order ID for the cart.
232232
*
233-
* @param int $reservedOrderId
233+
* @param string $reservedOrderId
234234
* @return $this
235235
*/
236236
public function setReservedOrderId($reservedOrderId);

0 commit comments

Comments
 (0)