Skip to content

Commit 115f50f

Browse files
[Magento Community Engineering] Community Contributions - 2.3-develop
- merged latest code from mainline branch
2 parents 9265124 + a6720f0 commit 115f50f

File tree

29 files changed

+1148
-415
lines changed

29 files changed

+1148
-415
lines changed

app/code/Magento/Catalog/Observer/SetSpecialPriceStartDate.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ public function execute(\Magento\Framework\Event\Observer $observer)
3838
{
3939
/** @var $product \Magento\Catalog\Model\Product */
4040
$product = $observer->getEvent()->getProduct();
41-
if ($product->getSpecialPrice() && ! $product->getSpecialFromDate()) {
41+
if ($product->getSpecialPrice() && $product->getSpecialFromDate() === null) {
4242
$product->setData('special_from_date', $this->localeDate->date()->setTime(0, 0));
4343
}
44-
4544
return $this;
4645
}
4746
}

app/code/Magento/CatalogSearch/Model/Search/RequestGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private function generateRequest($attributeType, $container, $useFulltext)
103103
}
104104
}
105105
/** @var $attribute Attribute */
106-
if (!$attribute->getIsSearchable() || in_array($attribute->getAttributeCode(), ['price', 'sku'], true)) {
106+
if (!$attribute->getIsSearchable() || in_array($attribute->getAttributeCode(), ['price'], true)) {
107107
// Some fields have their own specific handlers
108108
continue;
109109
}

app/code/Magento/CatalogSearch/Test/Unit/Model/Search/RequestGeneratorTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\CatalogSearch\Model\Search\RequestGenerator\GeneratorResolver;
1010
use Magento\CatalogSearch\Model\Search\RequestGenerator\GeneratorInterface;
1111

12+
/**
13+
* Test for \Magento\CatalogSearch\Model\Search\RequestGenerator
14+
*/
1215
class RequestGeneratorTest extends \PHPUnit\Framework\TestCase
1316
{
1417
/** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */
@@ -61,7 +64,7 @@ public function attributesProvider()
6164
return [
6265
[
6366
[
64-
'quick_search_container' => ['queries' => 0, 'filters' => 0, 'aggregations' => 0],
67+
'quick_search_container' => ['queries' => 1, 'filters' => 0, 'aggregations' => 0],
6568
'advanced_search_container' => ['queries' => 0, 'filters' => 0, 'aggregations' => 0],
6669
'catalog_view_container' => ['queries' => 0, 'filters' => 0, 'aggregations' => 0]
6770
],

app/code/Magento/CatalogSearch/etc/search_request.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
<queryReference clause="must" ref="visibility"/>
2020
</query>
2121
<query xsi:type="matchQuery" value="$search_term$" name="search">
22-
<match field="sku"/>
2322
<match field="*"/>
2423
</query>
2524
<query xsi:type="filteredQuery" name="category">

app/code/Magento/Checkout/Model/ShippingInformationManagement.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ public function saveAddressInformation(
191191

192192
$shippingAddress = $quote->getShippingAddress();
193193

194-
if (!$shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod())) {
194+
if (!$quote->getIsVirtual()
195+
&& !$shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod())
196+
) {
195197
throw new NoSuchEntityException(
196198
__('Carrier with such method not found: %1, %2', $carrierCode, $methodCode)
197199
);

app/code/Magento/Customer/Model/CustomerAuthUpdate.php

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,74 @@
66

77
namespace Magento\Customer\Model;
88

9+
use Magento\Customer\Model\ResourceModel\Customer as CustomerResourceModel;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\Exception\NoSuchEntityException;
12+
913
/**
1014
* Customer Authentication update model.
1115
*/
1216
class CustomerAuthUpdate
1317
{
1418
/**
15-
* @var \Magento\Customer\Model\CustomerRegistry
19+
* @var CustomerRegistry
1620
*/
1721
protected $customerRegistry;
1822

1923
/**
20-
* @var \Magento\Customer\Model\ResourceModel\Customer
24+
* @var CustomerResourceModel
2125
*/
2226
protected $customerResourceModel;
2327

2428
/**
25-
* @param \Magento\Customer\Model\CustomerRegistry $customerRegistry
26-
* @param \Magento\Customer\Model\ResourceModel\Customer $customerResourceModel
29+
* @var Customer
30+
*/
31+
private $customerModel;
32+
33+
/**
34+
* @param CustomerRegistry $customerRegistry
35+
* @param CustomerResourceModel $customerResourceModel
36+
* @param Customer|null $customerModel
2737
*/
2838
public function __construct(
29-
\Magento\Customer\Model\CustomerRegistry $customerRegistry,
30-
\Magento\Customer\Model\ResourceModel\Customer $customerResourceModel
39+
CustomerRegistry $customerRegistry,
40+
CustomerResourceModel $customerResourceModel,
41+
Customer $customerModel = null
3142
) {
3243
$this->customerRegistry = $customerRegistry;
3344
$this->customerResourceModel = $customerResourceModel;
45+
$this->customerModel = $customerModel ?: ObjectManager::getInstance()->get(Customer::class);
3446
}
3547

3648
/**
3749
* Reset Authentication data for customer.
3850
*
3951
* @param int $customerId
4052
* @return $this
53+
* @throws NoSuchEntityException
4154
*/
4255
public function saveAuth($customerId)
4356
{
4457
$customerSecure = $this->customerRegistry->retrieveSecureData($customerId);
4558

59+
$this->customerResourceModel->load($this->customerModel, $customerId);
60+
$currentLockExpiresVal = $this->customerModel->getData('lock_expires');
61+
$newLockExpiresVal = $customerSecure->getData('lock_expires');
62+
4663
$this->customerResourceModel->getConnection()->update(
4764
$this->customerResourceModel->getTable('customer_entity'),
4865
[
4966
'failures_num' => $customerSecure->getData('failures_num'),
5067
'first_failure' => $customerSecure->getData('first_failure'),
51-
'lock_expires' => $customerSecure->getData('lock_expires'),
68+
'lock_expires' => $newLockExpiresVal,
5269
],
5370
$this->customerResourceModel->getConnection()->quoteInto('entity_id = ?', $customerId)
5471
);
5572

73+
if ($currentLockExpiresVal !== $newLockExpiresVal) {
74+
$this->customerModel->reindex();
75+
}
76+
5677
return $this;
5778
}
5879
}

app/code/Magento/Customer/Test/Unit/Model/CustomerAuthUpdateTest.php

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55
*/
66
namespace Magento\Customer\Test\Unit\Model;
77

8+
use Magento\Customer\Model\Customer as CustomerModel;
89
use Magento\Customer\Model\CustomerAuthUpdate;
10+
use Magento\Customer\Model\CustomerRegistry;
11+
use Magento\Customer\Model\Data\CustomerSecure;
12+
use Magento\Customer\Model\ResourceModel\Customer as CustomerResourceModel;
13+
use Magento\Framework\DB\Adapter\AdapterInterface;
14+
use Magento\Framework\Exception\NoSuchEntityException;
15+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
916

1017
/**
1118
* Class CustomerAuthUpdateTest
@@ -18,17 +25,22 @@ class CustomerAuthUpdateTest extends \PHPUnit\Framework\TestCase
1825
protected $model;
1926

2027
/**
21-
* @var \Magento\Customer\Model\CustomerRegistry|\PHPUnit_Framework_MockObject_MockObject
28+
* @var CustomerRegistry|\PHPUnit_Framework_MockObject_MockObject
2229
*/
2330
protected $customerRegistry;
2431

2532
/**
26-
* @var \Magento\Customer\Model\ResourceModel\Customer|\PHPUnit_Framework_MockObject_MockObject
33+
* @var CustomerResourceModel|\PHPUnit_Framework_MockObject_MockObject
2734
*/
2835
protected $customerResourceModel;
2936

3037
/**
31-
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
38+
* @var CustomerModel|\PHPUnit_Framework_MockObject_MockObject
39+
*/
40+
protected $customerModel;
41+
42+
/**
43+
* @var ObjectManager
3244
*/
3345
protected $objectManager;
3446

@@ -37,32 +49,36 @@ class CustomerAuthUpdateTest extends \PHPUnit\Framework\TestCase
3749
*/
3850
protected function setUp()
3951
{
40-
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
52+
$this->objectManager = new ObjectManager($this);
4153

4254
$this->customerRegistry =
43-
$this->createMock(\Magento\Customer\Model\CustomerRegistry::class);
55+
$this->createMock(CustomerRegistry::class);
4456
$this->customerResourceModel =
45-
$this->createMock(\Magento\Customer\Model\ResourceModel\Customer::class);
57+
$this->createMock(CustomerResourceModel::class);
58+
$this->customerModel =
59+
$this->createMock(CustomerModel::class);
4660

4761
$this->model = $this->objectManager->getObject(
48-
\Magento\Customer\Model\CustomerAuthUpdate::class,
62+
CustomerAuthUpdate::class,
4963
[
5064
'customerRegistry' => $this->customerRegistry,
5165
'customerResourceModel' => $this->customerResourceModel,
66+
'customerModel' => $this->customerModel
5267
]
5368
);
5469
}
5570

5671
/**
5772
* test SaveAuth
73+
* @throws NoSuchEntityException
5874
*/
5975
public function testSaveAuth()
6076
{
6177
$customerId = 1;
6278

63-
$customerSecureMock = $this->createMock(\Magento\Customer\Model\Data\CustomerSecure::class);
79+
$customerSecureMock = $this->createMock(CustomerSecure::class);
6480

65-
$dbAdapter = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
81+
$dbAdapter = $this->createMock(AdapterInterface::class);
6682

6783
$this->customerRegistry->expects($this->once())
6884
->method('retrieveSecureData')
@@ -98,6 +114,9 @@ public function testSaveAuth()
98114
$customerId
99115
);
100116

117+
$this->customerModel->expects($this->once())
118+
->method('reindex');
119+
101120
$this->model->saveAuth($customerId);
102121
}
103122
}

app/code/Magento/Directory/Block/Data.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Directory\Block;
79

810
/**
@@ -173,10 +175,33 @@ public function getRegionCollection()
173175
* Returns region html select
174176
*
175177
* @return string
178+
* @deprecated
179+
* @see getRegionSelect() method for more configurations
176180
*/
177181
public function getRegionHtmlSelect()
178182
{
183+
return $this->getRegionSelect();
184+
}
185+
186+
/**
187+
* Returns region html select
188+
*
189+
* @param null|int $value
190+
* @param string $name
191+
* @param string $id
192+
* @param string $title
193+
* @return string
194+
*/
195+
public function getRegionSelect(
196+
?int $value = null,
197+
string $name = 'region',
198+
string $id = 'state',
199+
string $title = 'State/Province'
200+
): string {
179201
\Magento\Framework\Profiler::start('TEST: ' . __METHOD__, ['group' => 'TEST', 'method' => __METHOD__]);
202+
if ($value === null) {
203+
$value = (int)$this->getRegionId();
204+
}
180205
$cacheKey = 'DIRECTORY_REGION_SELECT_STORE' . $this->_storeManager->getStore()->getId();
181206
$cache = $this->_configCacheType->load($cacheKey);
182207
if ($cache) {
@@ -188,15 +213,15 @@ public function getRegionHtmlSelect()
188213
$html = $this->getLayout()->createBlock(
189214
\Magento\Framework\View\Element\Html\Select::class
190215
)->setName(
191-
'region'
216+
$name
192217
)->setTitle(
193-
__('State/Province')
218+
__($title)
194219
)->setId(
195-
'state'
220+
$id
196221
)->setClass(
197222
'required-entry validate-state'
198223
)->setValue(
199-
(int)$this->getRegionId()
224+
$value
200225
)->setOptions(
201226
$options
202227
)->getHtml();

app/code/Magento/Eav/Model/Validator/Attribute/Code.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Eav\Model\Validator\Attribute;
99

10+
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
1011
use Magento\Eav\Model\Entity\Attribute;
1112
use Magento\Framework\Exception\LocalizedException;
1213
use Magento\Framework\Validator\AbstractValidator;
@@ -65,6 +66,16 @@ public function isValid($attributeCode): bool
6566
);
6667
}
6768

69+
/**
70+
* Check attribute_code for prohibited prefix
71+
*/
72+
if (strpos($attributeCode, AbstractModifier::CONTAINER_PREFIX) === 0) {
73+
$errorMessages[] = __(
74+
'"%1" prefix is reserved by the system and cannot be used in attribute code names.',
75+
AbstractModifier::CONTAINER_PREFIX
76+
);
77+
}
78+
6879
$this->_addMessages($errorMessages);
6980

7081
return !$this->hasMessages();

app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/CodeTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ public function isValidDataProvider(): array
6161
], [
6262
'more_than_60_chars_more_than_60_chars_more_than_60_chars_more',
6363
false
64-
]
64+
], [
65+
'container_attribute',
66+
false,
67+
],
6568
];
6669
}
6770
}

0 commit comments

Comments
 (0)