Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/2.3-develop' into chaika_august2
Browse files Browse the repository at this point in the history
  • Loading branch information
olysenko committed Aug 15, 2018
2 parents ae05af1 + a7893f9 commit c123f05
Show file tree
Hide file tree
Showing 66 changed files with 767 additions and 278 deletions.
12 changes: 10 additions & 2 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,16 @@
&& isset($_SERVER['HTTP_ACCEPT'])
&& strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false
) {
\Magento\Framework\Profiler::applyConfig(
(isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER'])) ? $_SERVER['MAGE_PROFILER'] : trim(file_get_contents(BP . '/var/profiler.flag')),
$profilerConfig = isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER'])
? $_SERVER['MAGE_PROFILER']
: trim(file_get_contents(BP . '/var/profiler.flag'));

if ($profilerConfig) {
$profilerConfig = json_decode($profilerConfig, true) ?: $profilerConfig;
}

Magento\Framework\Profiler::applyConfig(
$profilerConfig,
BP,
!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(
}

/**
* Predispath admin action controller
* Predispatch admin action controller
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</actionGroup>

<!--Create new user with specified role-->
<actionGroup name="AdminCreateUser">
<actionGroup name="AdminCreateUserAction">
<click selector="{{AdminCreateUserSection.create}}" stepKey="clickToCreateNewUser"/>
<waitForPageLoad stepKey="waitForNewUserPageLoad" time="10"/>
<fillField selector="{{AdminCreateUserSection.usernameTextField}}" userInput="{{NewAdmin.username}}" stepKey="enterUserName" />
Expand Down Expand Up @@ -53,4 +53,4 @@
<see userInput="You deleted the user." stepKey="seeSuccessMessage" />
</actionGroup>

</actionGroups>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="CreateAnAdminOrderUsingBraintreePaymentTest1">
<annotations>
<features value="Backend"/>
Expand All @@ -17,6 +17,9 @@
<severity value="CRITICAL"/>
<testCaseId value="MAGETWO-93677"/>
<group value="braintree"/>
<skip>
<issueId value="MQE-1187" />
</skip>
</annotations>


Expand All @@ -42,7 +45,7 @@

<!--Create New User With Specific Role-->
<actionGroup ref="GoToAllUsers" stepKey="GoToAllUsers"/>
<actionGroup ref="AdminCreateUser" stepKey="AdminCreateNewUser"/>
<actionGroup ref="AdminCreateUserAction" stepKey="AdminCreateNewUser"/>

<!--SignOut-->
<actionGroup ref="SignOut" stepKey="signOutFromAdmin"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

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

use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\AbstractEav;
Expand All @@ -12,6 +14,11 @@
*/
abstract class AbstractAction
{
/**
* Config path for enable EAV indexer
*/
const ENABLE_EAV_INDEXER = 'catalog/search/enable_eav_indexer';

/**
* EAV Indexers by type
*
Expand All @@ -29,17 +36,27 @@ abstract class AbstractAction
*/
protected $_eavDecimalFactory;

/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
private $scopeConfig;

/**
* AbstractAction constructor.
* @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalFactory $eavDecimalFactory
* @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory $eavSourceFactory
* @param \Magento\Framework\App\Config\ScopeConfigInterface|null $scopeConfig
*/
public function __construct(
\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalFactory $eavDecimalFactory,
\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory $eavSourceFactory
\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory $eavSourceFactory,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig = null
) {
$this->_eavDecimalFactory = $eavDecimalFactory;
$this->_eavSourceFactory = $eavSourceFactory;
$this->scopeConfig = $scopeConfig ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\App\Config\ScopeConfigInterface::class
);
}

/**
Expand Down Expand Up @@ -92,6 +109,9 @@ public function getIndexer($type)
*/
public function reindex($ids = null)
{
if (!$this->isEavIndexerEnabled()) {
return;
}
foreach ($this->getIndexers() as $indexer) {
if ($ids === null) {
$indexer->reindexAll();
Expand Down Expand Up @@ -149,4 +169,19 @@ protected function processRelations(AbstractEav $indexer, array $ids, bool $only

return array_unique(array_merge($ids, $childIds, $parentIds));
}

/**
* Get EAV indexer status
*
* @return bool
*/
private function isEavIndexerEnabled(): bool
{
$eavIndexerStatus = $this->scopeConfig->getValue(
self::ENABLE_EAV_INDEXER,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);

return (bool)$eavIndexerStatus;
}
}
35 changes: 33 additions & 2 deletions app/code/Magento/Catalog/Model/Indexer/Product/Eav/Action/Full.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

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

use Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher;

/**
* Class Full reindex action
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Full extends \Magento\Catalog\Model\Indexer\Product\Eav\AbstractAction
{
Expand All @@ -32,23 +35,33 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Eav\AbstractAction
*/
private $activeTableSwitcher;

/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
private $scopeConfig;

/**
* @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalFactory $eavDecimalFactory
* @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory $eavSourceFactory
* @param \Magento\Framework\EntityManager\MetadataPool|null $metadataPool
* @param \Magento\Framework\Indexer\BatchProviderInterface|null $batchProvider
* @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\BatchSizeCalculator $batchSizeCalculator
* @param ActiveTableSwitcher|null $activeTableSwitcher
* @param \Magento\Framework\App\Config\ScopeConfigInterface|null $scopeConfig
*/
public function __construct(
\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalFactory $eavDecimalFactory,
\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory $eavSourceFactory,
\Magento\Framework\EntityManager\MetadataPool $metadataPool = null,
\Magento\Framework\Indexer\BatchProviderInterface $batchProvider = null,
\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\BatchSizeCalculator $batchSizeCalculator = null,
ActiveTableSwitcher $activeTableSwitcher = null
ActiveTableSwitcher $activeTableSwitcher = null,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig = null
) {
parent::__construct($eavDecimalFactory, $eavSourceFactory);
$this->scopeConfig = $scopeConfig ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\App\Config\ScopeConfigInterface::class
);
parent::__construct($eavDecimalFactory, $eavSourceFactory, $scopeConfig);
$this->metadataPool = $metadataPool ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\EntityManager\MetadataPool::class
);
Expand All @@ -73,6 +86,9 @@ public function __construct(
*/
public function execute($ids = null)
{
if (!$this->isEavIndexerEnabled()) {
return;
}
try {
foreach ($this->getIndexers() as $indexerName => $indexer) {
$connection = $indexer->getConnection();
Expand Down Expand Up @@ -129,4 +145,19 @@ protected function syncData($indexer, $destinationTable, $ids = null)
throw $e;
}
}

/**
* Get EAV indexer status
*
* @return bool
*/
private function isEavIndexerEnabled(): bool
{
$eavIndexerStatus = $this->scopeConfig->getValue(
self::ENABLE_EAV_INDEXER,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);

return (bool)$eavIndexerStatus;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ class AbstractActionTest extends \PHPUnit\Framework\TestCase
*/
protected $_eavSourceFactoryMock;

/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $scopeConfig;

/**
* @return void
*/
protected function setUp()
{
$this->_eavDecimalFactoryMock = $this->createPartialMock(
Expand All @@ -32,12 +40,22 @@ protected function setUp()
\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory::class,
['create']
);
$this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->_model = $this->getMockForAbstractClass(
\Magento\Catalog\Model\Indexer\Product\Eav\AbstractAction::class,
[$this->_eavDecimalFactoryMock, $this->_eavSourceFactoryMock, []]
[
$this->_eavDecimalFactoryMock,
$this->_eavSourceFactoryMock,
$this->scopeConfig
]
);
}

/**
* @return void
*/
public function testGetIndexers()
{
$expectedIndexers = [
Expand Down Expand Up @@ -73,6 +91,10 @@ public function testGetIndexerWithUnknownTypeThrowsException()
$this->_model->getIndexer('unknown_type');
}

/**
* @return void
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function testGetIndexer()
{
$this->_eavSourceFactoryMock->expects($this->once())
Expand All @@ -86,6 +108,10 @@ public function testGetIndexer()
$this->assertEquals('source_return_value', $this->_model->getIndexer('source'));
}

/**
* @return void
* @throws \Exception
*/
public function testReindexWithoutArgumentsExecutesReindexAll()
{
$eavSource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Source::class)
Expand All @@ -110,6 +136,10 @@ public function testReindexWithoutArgumentsExecutesReindexAll()
->method('create')
->will($this->returnValue($eavDecimal));

$this->scopeConfig->expects($this->once())
->method('getValue')
->willReturn(1);

$this->_model->reindex();
}

Expand Down Expand Up @@ -174,9 +204,25 @@ public function testReindexWithNotNullArgumentExecutesReindexEntities(
->method('create')
->will($this->returnValue($eavDecimal));

$this->scopeConfig->expects($this->once())
->method('getValue')
->willReturn(1);

$this->_model->reindex($ids);
}

/**
* @return void
* @throws \Exception
*/
public function testReindexWithDisabledEavIndexer()
{
$this->scopeConfig->expects($this->once())->method('getValue')->willReturn(0);
$this->_eavSourceFactoryMock->expects($this->never())->method('create');
$this->_eavDecimalFactoryMock->expects($this->never())->method('create');
$this->_model->reindex();
}

/**
* @return array
*/
Expand Down
Loading

0 comments on commit c123f05

Please sign in to comment.