Skip to content

Commit edeb857

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into 2.3-develop-pr12
2 parents 4af33e7 + f5debf0 commit edeb857

File tree

100 files changed

+335
-342
lines changed

Some content is hidden

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

100 files changed

+335
-342
lines changed

app/code/Magento/Backend/Test/Unit/Model/Config/SessionLifetime/BackendModelTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public function testBeforeSave($value, $errorMessage = null)
2121
\Magento\Backend\Model\Config\SessionLifetime\BackendModel::class
2222
);
2323
if ($errorMessage !== null) {
24-
$this->expectException(\Magento\Framework\Exception\LocalizedException::class, $errorMessage);
24+
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
25+
$this->expectExceptionMessage($errorMessage);
2526
}
2627
$model->setValue($value);
2728
$object = $model->beforeSave();

app/code/Magento/Captcha/Test/Unit/Model/CaptchaFactoryTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,9 @@ public function testCreateNegative()
5454
$this->returnValue($defaultCaptchaMock)
5555
);
5656

57-
$this->expectException(
58-
'InvalidArgumentException',
59-
'Magento\Captcha\Model\\' . ucfirst(
60-
$captchaType
61-
) . ' does not implement \Magento\Captcha\Model\CaptchaInterface'
62-
);
57+
$this->expectException('InvalidArgumentException');
58+
$this->expectExceptionMessage('Magento\Captcha\Model\\' . ucfirst($captchaType) .
59+
' does not implement \Magento\Captcha\Model\CaptchaInterface');
6360

6461
$this->assertEquals($defaultCaptchaMock, $this->_model->create($captchaType, 'form_id'));
6562
}

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ protected function setUp()
2727

2828
public function testCreateWithInvalidType()
2929
{
30-
$this->expectException(
31-
'\InvalidArgumentException',
32-
\Magento\Framework\DataObject::class . ' does not implement ' .
33-
\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface::class
34-
);
30+
$this->expectException('\InvalidArgumentException');
31+
$this->expectExceptionMessage(\Magento\Framework\DataObject::class . ' does not implement ' .
32+
\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface::class);
3533
$this->_objectManagerMock->expects($this->never())->method('create');
3634
$this->_model->create(\Magento\Framework\DataObject::class);
3735
}

app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ public function testSaveWithException()
255255
*/
256256
public function testSaveWithValidateCategoryException($error, $expectedException, $expectedExceptionMessage)
257257
{
258-
$this->expectException($expectedException, $expectedExceptionMessage);
258+
$this->expectException($expectedException);
259+
$this->expectExceptionMessage($expectedExceptionMessage);
259260
$categoryId = 5;
260261
$categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
261262
$this->extensibleDataObjectConverterMock
@@ -284,7 +285,7 @@ public function saveWithValidateCategoryExceptionDataProvider()
284285
return [
285286
[
286287
true, \Magento\Framework\Exception\CouldNotSaveException::class,
287-
'Could not save category: Attribute "ValidateCategoryTest" is required.',
288+
'Could not save category: The "ValidateCategoryTest" attribute is required. Enter and try again.'
288289
], [
289290
'Something went wrong', \Magento\Framework\Exception\CouldNotSaveException::class,
290291
'Could not save category: Something went wrong'

app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/FullTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public function testExecuteWithAdapterErrorThrowsException()
4848
$tableSwitcherMock
4949
);
5050

51-
$this->expectException(\Magento\Framework\Exception\LocalizedException::class, $exceptionMessage);
51+
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
52+
$this->expectExceptionMessage($exceptionMessage);
5253

5354
$model->execute();
5455
}

app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructorFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ protected function setUp()
2727

2828
public function testCreateWithInvalidType()
2929
{
30-
$this->expectException(
31-
'\InvalidArgumentException',
30+
$this->expectException('\InvalidArgumentException');
31+
$this->expectExceptionMessage(
3232
'Magento\Framework\DataObject does not implement \Magento\Catalog\Model\Product\CopyConstructorInterface'
3333
);
3434
$this->_objectManagerMock->expects($this->never())->method('create');

app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/FullTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public function testExecuteWithAdapterErrorThrowsException()
4444
]
4545
);
4646

47-
$this->expectException(\Magento\Framework\Exception\LocalizedException::class, $exceptionMessage);
47+
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
48+
$this->expectExceptionMessage($exceptionMessage);
4849

4950
$model->execute();
5051
}

app/code/Magento/CatalogRule/Model/Rule.php

Lines changed: 61 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,33 @@
66
namespace Magento\CatalogRule\Model;
77

88
use Magento\Catalog\Model\Product;
9+
use Magento\Catalog\Model\ProductFactory;
10+
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
11+
use Magento\CatalogRule\Api\Data\RuleExtensionInterface;
912
use Magento\CatalogRule\Api\Data\RuleInterface;
13+
use Magento\CatalogRule\Helper\Data;
14+
use Magento\CatalogRule\Model\Data\Condition\Converter;
15+
use Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor;
16+
use Magento\CatalogRule\Model\ResourceModel\Rule as RuleResourceModel;
17+
use Magento\CatalogRule\Model\Rule\Action\CollectionFactory as RuleCollectionFactory;
18+
use Magento\CatalogRule\Model\Rule\Condition\CombineFactory;
19+
use Magento\Customer\Model\Session;
1020
use Magento\Framework\Api\AttributeValueFactory;
1121
use Magento\Framework\Api\ExtensionAttributesFactory;
22+
use Magento\Framework\App\Cache\TypeListInterface;
23+
use Magento\Framework\App\ObjectManager;
24+
use Magento\Framework\Data\Collection\AbstractDb;
25+
use Magento\Framework\Data\FormFactory;
26+
use Magento\Framework\DataObject;
1227
use Magento\Framework\DataObject\IdentityInterface;
28+
use Magento\Framework\Model\Context;
29+
use Magento\Framework\Model\ResourceModel\AbstractResource;
30+
use Magento\Framework\Model\ResourceModel\Iterator;
31+
use Magento\Framework\Registry;
32+
use Magento\Framework\Serialize\Serializer\Json;
33+
use Magento\Framework\Stdlib\DateTime;
34+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
35+
use Magento\Store\Model\StoreManagerInterface;
1336

1437
/**
1538
* Catalog Rule data model
@@ -136,6 +159,11 @@ class Rule extends \Magento\Rule\Model\AbstractModel implements RuleInterface, I
136159
*/
137160
protected $ruleConditionConverter;
138161

162+
/**
163+
* @var RuleResourceModel
164+
*/
165+
private $ruleResourceModel;
166+
139167
/**
140168
* Rule constructor
141169
*
@@ -161,32 +189,33 @@ class Rule extends \Magento\Rule\Model\AbstractModel implements RuleInterface, I
161189
* @param ExtensionAttributesFactory|null $extensionFactory
162190
* @param AttributeValueFactory|null $customAttributeFactory
163191
* @param \Magento\Framework\Serialize\Serializer\Json $serializer
164-
*
192+
* @param \Magento\CatalogRule\Model\ResourceModel\RuleResourceModel|null $ruleResourceModel
165193
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
166194
*/
167195
public function __construct(
168-
\Magento\Framework\Model\Context $context,
169-
\Magento\Framework\Registry $registry,
170-
\Magento\Framework\Data\FormFactory $formFactory,
171-
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
172-
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
173-
\Magento\Store\Model\StoreManagerInterface $storeManager,
174-
\Magento\CatalogRule\Model\Rule\Condition\CombineFactory $combineFactory,
175-
\Magento\CatalogRule\Model\Rule\Action\CollectionFactory $actionCollectionFactory,
176-
\Magento\Catalog\Model\ProductFactory $productFactory,
177-
\Magento\Framework\Model\ResourceModel\Iterator $resourceIterator,
178-
\Magento\Customer\Model\Session $customerSession,
179-
\Magento\CatalogRule\Helper\Data $catalogRuleData,
180-
\Magento\Framework\App\Cache\TypeListInterface $cacheTypesList,
181-
\Magento\Framework\Stdlib\DateTime $dateTime,
182-
\Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor $ruleProductProcessor,
183-
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
184-
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
196+
Context $context,
197+
Registry $registry,
198+
FormFactory $formFactory,
199+
TimezoneInterface $localeDate,
200+
CollectionFactory $productCollectionFactory,
201+
StoreManagerInterface $storeManager,
202+
CombineFactory $combineFactory,
203+
RuleCollectionFactory $actionCollectionFactory,
204+
ProductFactory $productFactory,
205+
Iterator $resourceIterator,
206+
Session $customerSession,
207+
Data $catalogRuleData,
208+
TypeListInterface $cacheTypesList,
209+
DateTime $dateTime,
210+
RuleProductProcessor $ruleProductProcessor,
211+
AbstractResource $resource = null,
212+
AbstractDb $resourceCollection = null,
185213
array $relatedCacheTypes = [],
186214
array $data = [],
187215
ExtensionAttributesFactory $extensionFactory = null,
188216
AttributeValueFactory $customAttributeFactory = null,
189-
\Magento\Framework\Serialize\Serializer\Json $serializer = null
217+
Json $serializer = null,
218+
RuleResourceModel $ruleResourceModel = null
190219
) {
191220
$this->_productCollectionFactory = $productCollectionFactory;
192221
$this->_storeManager = $storeManager;
@@ -200,6 +229,7 @@ public function __construct(
200229
$this->_relatedCacheTypes = $relatedCacheTypes;
201230
$this->dateTime = $dateTime;
202231
$this->_ruleProductProcessor = $ruleProductProcessor;
232+
$this->ruleResourceModel = $ruleResourceModel ?: ObjectManager::getInstance()->get(RuleResourceModel::class);
203233

204234
parent::__construct(
205235
$context,
@@ -223,7 +253,7 @@ public function __construct(
223253
protected function _construct()
224254
{
225255
parent::_construct();
226-
$this->_init(\Magento\CatalogRule\Model\ResourceModel\Rule::class);
256+
$this->_init(RuleResourceModel::class);
227257
$this->setIdFieldName('rule_id');
228258
}
229259

@@ -255,7 +285,7 @@ public function getActionsInstance()
255285
public function getCustomerGroupIds()
256286
{
257287
if (!$this->hasCustomerGroupIds()) {
258-
$customerGroupIds = $this->_getResource()->getCustomerGroupIds($this->getId());
288+
$customerGroupIds = $this->ruleResourceModel->getCustomerGroupIds($this->getId());
259289
$this->setData('customer_group_ids', (array)$customerGroupIds);
260290
}
261291
return $this->_getData('customer_group_ids');
@@ -269,7 +299,7 @@ public function getCustomerGroupIds()
269299
public function getNow()
270300
{
271301
if (!$this->_now) {
272-
return (new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
302+
return (new \DateTime())->format(DateTime::DATETIME_PHP_FORMAT);
273303
}
274304
return $this->_now;
275305
}
@@ -363,7 +393,7 @@ protected function _getWebsitesMap()
363393
/**
364394
* {@inheritdoc}
365395
*/
366-
public function validateData(\Magento\Framework\DataObject $dataObject)
396+
public function validateData(DataObject $dataObject)
367397
{
368398
$result = parent::validateData($dataObject);
369399
if ($result === true) {
@@ -470,7 +500,7 @@ public function calcProductPriceRule(Product $product, $price)
470500
*/
471501
protected function _getRulesFromProduct($dateTs, $websiteId, $customerGroupId, $productId)
472502
{
473-
return $this->_getResource()->getRulesFromProduct($dateTs, $websiteId, $customerGroupId, $productId);
503+
return $this->ruleResourceModel->getRulesFromProduct($dateTs, $websiteId, $customerGroupId, $productId);
474504
}
475505

476506
/**
@@ -516,10 +546,10 @@ protected function _invalidateCache()
516546
*/
517547
public function afterSave()
518548
{
519-
if ($this->isObjectNew()) {
520-
$this->getMatchingProductIds();
521-
if (!empty($this->_productIds) && is_array($this->_productIds)) {
522-
$this->_getResource()->addCommitCallback([$this, 'reindex']);
549+
if ($this->isObjectNew() && !$this->_ruleProductProcessor->isIndexerScheduled()) {
550+
$productIds = $this->getMatchingProductIds();
551+
if (!empty($productIds) && is_array($productIds)) {
552+
$this->ruleResourceModel->addCommitCallback([$this, 'reindex']);
523553
}
524554
} else {
525555
$this->_ruleProductProcessor->getIndexer()->invalidate();
@@ -778,7 +808,7 @@ public function getExtensionAttributes()
778808
* @param \Magento\CatalogRule\Api\Data\RuleExtensionInterface $extensionAttributes
779809
* @return $this
780810
*/
781-
public function setExtensionAttributes(\Magento\CatalogRule\Api\Data\RuleExtensionInterface $extensionAttributes)
811+
public function setExtensionAttributes(RuleExtensionInterface $extensionAttributes)
782812
{
783813
return $this->_setExtensionAttributes($extensionAttributes);
784814
}
@@ -790,8 +820,8 @@ public function setExtensionAttributes(\Magento\CatalogRule\Api\Data\RuleExtensi
790820
private function getRuleConditionConverter()
791821
{
792822
if (null === $this->ruleConditionConverter) {
793-
$this->ruleConditionConverter = \Magento\Framework\App\ObjectManager::getInstance()
794-
->get(\Magento\CatalogRule\Model\Data\Condition\Converter::class);
823+
$this->ruleConditionConverter = ObjectManager::getInstance()
824+
->get(Converter::class);
795825
}
796826
return $this->ruleConditionConverter;
797827
}

app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</span>
2626
</a>
2727
<?php if ($block->getIsNeedToDisplaySideBar()): ?>
28-
<div class="block block-minicart empty"
28+
<div class="block block-minicart"
2929
data-role="dropdownDialog"
3030
data-mage-init='{"dropdownDialog":{
3131
"appendTo":"[data-block=minicart]",

app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,8 @@ public function testGetCurrentPath($pathId, $expectedPath, $isExist)
379379

380380
public function testGetCurrentPathThrowException()
381381
{
382-
$this->expectException(
383-
\Magento\Framework\Exception\LocalizedException::class,
384-
'The directory PATH/wysiwyg is not writable by server.'
385-
);
382+
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
383+
$this->expectExceptionMessage('The directory PATH is not writable by server.');
386384

387385
$this->directoryWriteMock->expects($this->once())
388386
->method('isExist')

0 commit comments

Comments
 (0)