Skip to content

Commit

Permalink
Merge pull request #29733 from magento/MC-36959
Browse files Browse the repository at this point in the history
MC-36959 Remove "compareArraysRecursively" logic duplication
  • Loading branch information
mslabko authored Aug 25, 2020
2 parents d237645 + db188b6 commit 7f18db2
Show file tree
Hide file tree
Showing 135 changed files with 1,760 additions and 1,055 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminNavigateToEmailToFriendSettingsActionGroup">
<amOnPage url="{{AdminConfigurationEmailToFriendPage.url}}" stepKey="navigateToPersistencePage"/>
<conditionalClick selector="{{AdminEmailToFriendSection.DefaultLayoutsTab}}" dependentSelector="{{AdminEmailToFriendSection.CheckIfTabExpand}}" visible="true" stepKey="clickTab"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertAdminEmailToFriendOptionsAvailableActionGroup">
<seeElement stepKey="seeEmailTemplateInput" selector="{{AdminEmailToFriendSection.emailTemplate}}"/>
<seeElement stepKey="seeAllowForGuestsInput" selector="{{AdminEmailToFriendSection.allowForGuests}}"/>
<seeElement stepKey="seeMaxRecipientsInput" selector="{{AdminEmailToFriendSection.maxRecipients}}"/>
<seeElement stepKey="seeMaxPerHourInput" selector="{{AdminEmailToFriendSection.maxPerHour}}"/>
<seeElement stepKey="seeLimitSendingBy" selector="{{AdminEmailToFriendSection.limitSendingBy}}"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
<page name="AdminConfigurationEmailToFriendPage" url="admin/system_config/edit/section/sendfriend/" module="Catalog" area="admin">
<section name="AdminEmailToFriendSection"/>
</page>
</pages>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminCatalogEmailToFriendSettingsTest">
<annotations>
<features value="Backend"/>
<stories value="Enable Email To A Friend Functionality"/>
<title value="Admin should be able to manage settings of Email To A Friend Functionality"/>
<description value="Admin should be able to enable Email To A Friend functionality in Magento Admin backend and see additional options"/>
<group value="backend"/>
<severity value="MINOR"></severity>
<testCaseId value="MC-35895"/>
</annotations>

<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<magentoCLI stepKey="enableSendFriend" command="config:set sendfriend/email/enabled 1"/>
<magentoCLI stepKey="cacheClean" command="cache:clean config"/>
</before>
<after>
<magentoCLI stepKey="disableSendFriend" command="config:set sendfriend/email/enabled 0"/>
<magentoCLI stepKey="cacheClean" command="cache:clean config"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>

<actionGroup ref="AdminNavigateToEmailToFriendSettingsActionGroup" stepKey="navigateToSendFriendSettings"/>
<actionGroup ref="AssertAdminEmailToFriendOptionsAvailableActionGroup" stepKey="assertOptions"/>
</test>
</tests>
2 changes: 1 addition & 1 deletion app/code/Magento/Captcha/CustomerData/Captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(
/**
* @inheritdoc
*/
public function getSectionData() :array
public function getSectionData(): array
{
$data = [];

Expand Down
35 changes: 18 additions & 17 deletions app/code/Magento/Catalog/Model/CategoryLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,41 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Model;

use Magento\Catalog\Api\Data\CategoryLinkExtensionInterface;
use Magento\Catalog\Api\Data\CategoryLinkInterface;
use Magento\Framework\Model\AbstractExtensibleModel;

/**
* @codeCoverageIgnore
*/
class CategoryLink extends \Magento\Framework\Api\AbstractExtensibleObject implements
\Magento\Catalog\Api\Data\CategoryLinkInterface
class CategoryLink extends AbstractExtensibleModel implements CategoryLinkInterface
{
/**#@+
* Constants
*/
const KEY_POSITION = 'position';
const KEY_CATEGORY_ID = 'category_id';
/**#@-*/
public const KEY_POSITION = 'position';
public const KEY_CATEGORY_ID = 'category_id';

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getPosition()
{
return $this->_get(self::KEY_POSITION);
return $this->getData(self::KEY_POSITION);
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getCategoryId()
{
return $this->_get(self::KEY_CATEGORY_ID);
return $this->getData(self::KEY_CATEGORY_ID);
}

/**
* @inheritDoc
*
* @param int $position
* @return $this
*/
Expand All @@ -56,7 +58,7 @@ public function setCategoryId($categoryId)
}

/**
* {@inheritdoc}
* @inheritdoc
*
* @return \Magento\Catalog\Api\Data\CategoryLinkExtensionInterface|null
*/
Expand All @@ -66,14 +68,13 @@ public function getExtensionAttributes()
}

/**
* {@inheritdoc}
* @inheritdoc
*
* @param \Magento\Catalog\Api\Data\CategoryLinkExtensionInterface $extensionAttributes
* @return $this
*/
public function setExtensionAttributes(
\Magento\Catalog\Api\Data\CategoryLinkExtensionInterface $extensionAttributes
) {
public function setExtensionAttributes(CategoryLinkExtensionInterface $extensionAttributes)
{
return $this->_setExtensionAttributes($extensionAttributes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@
*/
namespace Magento\Catalog\Model\Indexer\Category\Flat\Plugin;

use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Catalog\Model\Indexer\Category\Flat\State;
use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;

class StoreGroup
{
/**
* @var bool
*/
private $needInvalidating;

/**
* @var IndexerRegistry
*/
Expand Down Expand Up @@ -48,35 +43,21 @@ protected function validate(AbstractModel $group)
return $group->dataHasChangedFor('root_category_id') && !$group->isObjectNew();
}

/**
* Check if need invalidate flat category indexer
*
* @param AbstractDb $subject
* @param AbstractModel $group
*
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(AbstractDb $subject, AbstractModel $group)
{
$this->needInvalidating = $this->validate($group);
}

/**
* Invalidate flat category indexer if root category changed for store group
*
* @param AbstractDb $subject
* @param AbstractDb $objectResource
*
* @param AbstractDb $result
* @param AbstractModel $group
* @return AbstractDb
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterSave(AbstractDb $subject, AbstractDb $objectResource)
public function afterSave(AbstractDb $subject, AbstractDb $result, AbstractModel $group)
{
if ($this->needInvalidating && $this->state->isFlatEnabled()) {
if ($this->validate($group) && $this->state->isFlatEnabled()) {
$this->indexerRegistry->get(State::INDEXER_ID)->invalidate();
}

return $objectResource;
return $result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@
*/
namespace Magento\Catalog\Model\Indexer\Category\Product\Plugin;

use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\Model\AbstractModel;
use Magento\Catalog\Model\Indexer\Category\Product;
use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer;
use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;

class StoreGroup
{
/**
* @var bool
*/
private $needInvalidating;

/**
* @var IndexerRegistry
*/
Expand All @@ -40,36 +35,23 @@ public function __construct(
$this->tableMaintainer = $tableMaintainer;
}

/**
* Check if need invalidate flat category indexer
*
* @param AbstractDb $subject
* @param AbstractModel $group
*
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(AbstractDb $subject, AbstractModel $group)
{
$this->needInvalidating = $this->validate($group);
}

/**
* Invalidate flat product
*
* @param AbstractDb $subject
* @param AbstractDb $objectResource
* @param AbstractDb $result
* @param AbstractModel $group
*
* @return AbstractDb
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterSave(AbstractDb $subject, AbstractDb $objectResource)
public function afterSave(AbstractDb $subject, AbstractDb $result, AbstractModel $group)
{
if ($this->needInvalidating) {
if ($this->validate($group)) {
$this->indexerRegistry->get(Product::INDEXER_ID)->invalidate();
}

return $objectResource;
return $result;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
*/
namespace Magento\Catalog\Model\Indexer\Category\Product\Plugin;

use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;

class StoreView extends StoreGroup
{
/**
* Validate changes for invalidating indexer
*
* @param \Magento\Framework\Model\AbstractModel $store
* @param AbstractModel $store
* @return bool
*/
protected function validate(\Magento\Framework\Model\AbstractModel $store)
protected function validate(AbstractModel $store)
{
return $store->isObjectNew() || $store->dataHasChangedFor('group_id');
}
Expand All @@ -36,7 +36,7 @@ public function afterSave(AbstractDb $subject, AbstractDb $objectResource, Abstr
$this->tableMaintainer->createTablesForStore($store->getId());
}

return parent::afterSave($subject, $objectResource);
return parent::afterSave($subject, $objectResource, $store);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,46 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Model\Indexer\Product\Eav\Plugin;

use Magento\Catalog\Model\Indexer\Product\Eav\Processor;
use Magento\Framework\Model\AbstractModel;
use Magento\Store\Model\ResourceModel\Store;

class StoreView
{
/**
* Product attribute indexer processor
*
* @var \Magento\Catalog\Model\Indexer\Product\Eav\Processor
* @var Processor
*/
protected $_indexerEavProcessor;

/**
* @param \Magento\Catalog\Model\Indexer\Product\Eav\Processor $indexerEavProcessor
* @param Processor $indexerEavProcessor
*/
public function __construct(\Magento\Catalog\Model\Indexer\Product\Eav\Processor $indexerEavProcessor)
public function __construct(Processor $indexerEavProcessor)
{
$this->_indexerEavProcessor = $indexerEavProcessor;
}

/**
* Before save handler
*
* @param \Magento\Store\Model\ResourceModel\Store $subject
* @param \Magento\Framework\Model\AbstractModel $object
* @param Store $subject
* @param Store $result
* @param AbstractModel $object
*
* @return void
* @return Store
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(
\Magento\Store\Model\ResourceModel\Store $subject,
\Magento\Framework\Model\AbstractModel $object
) {
if ((!$object->getId() || $object->dataHasChangedFor('group_id')) && $object->getIsActive()) {
public function afterSave(Store $subject, Store $result, AbstractModel $object)
{
if (($object->isObjectNew() || $object->dataHasChangedFor('group_id')) && $object->getIsActive()) {
$this->_indexerEavProcessor->markIndexerAsInvalid();
}

return $result;
}
}
Loading

0 comments on commit 7f18db2

Please sign in to comment.