Skip to content

Commit

Permalink
merge magento/2.4-develop into magento-performance/MC-33086-catalog-e…
Browse files Browse the repository at this point in the history
…vent
  • Loading branch information
magento-mts-svc committed Apr 14, 2020
2 parents 9dc6c62 + c4a7d77 commit 6ee27c1
Show file tree
Hide file tree
Showing 47 changed files with 639 additions and 436 deletions.
22 changes: 13 additions & 9 deletions app/code/Magento/Amqp/Test/Unit/Setup/ConfigOptionsListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@

namespace Magento\Amqp\Test\Unit\Setup;

use Magento\Amqp\Setup\ConnectionValidator;
use Magento\Framework\Config\Data\ConfigData;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Amqp\Setup\ConfigOptionsList;
use Magento\Framework\Setup\Option\TextConfigOption;
use Magento\Framework\App\DeploymentConfig;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class ConfigOptionsListTest extends \PHPUnit\Framework\TestCase
class ConfigOptionsListTest extends TestCase
{
/**
* @var ObjectManager
Expand All @@ -24,12 +28,12 @@ class ConfigOptionsListTest extends \PHPUnit\Framework\TestCase
private $model;

/**
* @var \Magento\Amqp\Setup\ConnectionValidator|\PHPUnit_Framework_MockObject_MockObject
* @var ConnectionValidator|MockObject
*/
private $connectionValidatorMock;

/**
* @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject
* @var DeploymentConfig|MockObject
*/
private $deploymentConfigMock;

Expand All @@ -38,7 +42,7 @@ class ConfigOptionsListTest extends \PHPUnit\Framework\TestCase
*/
private $options;

protected function setUp()
protected function setUp(): void
{
$this->options = [
ConfigOptionsList::INPUT_KEY_QUEUE_AMQP_HOST => 'host',
Expand All @@ -51,18 +55,18 @@ protected function setUp()
];

$this->objectManager = new ObjectManager($this);
$this->connectionValidatorMock = $this->getMockBuilder(\Magento\Amqp\Setup\ConnectionValidator::class)
$this->connectionValidatorMock = $this->getMockBuilder(ConnectionValidator::class)
->disableOriginalConstructor()
->setMethods([])
->getMock();

$this->deploymentConfigMock = $this->getMockBuilder(\Magento\Framework\App\DeploymentConfig::class)
$this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class)
->disableOriginalConstructor()
->setMethods([])
->getMock();

$this->model = $this->objectManager->getObject(
\Magento\Amqp\Setup\ConfigOptionsList::class,
ConfigOptionsList::class,
[
'connectionValidator' => $this->connectionValidatorMock,
]
Expand Down Expand Up @@ -135,9 +139,9 @@ public function testCreateConfig($options, $expectedConfigData)
$result = $this->model->createConfig($options, $this->deploymentConfigMock);
$this->assertInternalType('array', $result);
$this->assertNotEmpty($result);
/** @var \Magento\Framework\Config\Data\ConfigData $configData */
/** @var ConfigData $configData */
$configData = $result[0];
$this->assertInstanceOf(\Magento\Framework\Config\Data\ConfigData::class, $configData);
$this->assertInstanceOf(ConfigData::class, $configData);
$this->assertEquals($expectedConfigData, $configData->getData());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
<waitForLoadingMaskToDisappear stepKey="waitForSearchingOrder"/>
<!-- Create invoice -->
<comment userInput="Create invoice" stepKey="createInvoice"/>
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/>
<waitForPageLoad stepKey="waitForOrderPageToLoad"/>

<actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/>
<click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceButton"/>
<waitForPageLoad stepKey="waitForInvoicePageToLoad"/>
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Invoice" stepKey="seeNewInvoiceInPageTitle" after="clickInvoiceButton"/>
Expand All @@ -95,8 +95,7 @@
<comment userInput="Create Shipment for the order" stepKey="createShipmentForOrder"/>
<amOnPage url="{{AdminOrdersPage.url}}" stepKey="onOrdersPage2"/>
<waitForPageLoad time="30" stepKey="waitForOrderListPageLoading"/>
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="openOrderPageForShip"/>
<waitForPageLoad stepKey="waitForOrderDetailsPage"/>
<actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="openOrderPageForShip"/>
<click selector="{{AdminOrderDetailsMainActionsSection.ship}}" stepKey="clickShipAction"/>
<waitForPageLoad stepKey="waitForShipmentPagePage"/>
<seeInCurrentUrl url="{{AdminShipmentNewPage.url}}" stepKey="seeOrderShipmentUrl"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
<actionGroup ref="FilterOrderGridByIdActionGroup" stepKey="filterOrderById">
<argument name="orderId" value="$grabOrderNumber"/>
</actionGroup>
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/>
<waitForPageLoad stepKey="waitForAdminOrderPageLoad"/>

<actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/>
<scrollTo selector="{{AdminOrderTotalSection.subTotal}}" stepKey="scrollToOrderTotalSection"/>
<see selector="{{AdminOrderTotalSection.subTotal}}" userInput="$0.00" stepKey="checkSubtotal"/>
</test>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@
<actionGroup ref="FilterOrderGridByIdActionGroup" stepKey="openOrdersGrid">
<argument name="orderId" value="{$grabOrderNumber}"/>
</actionGroup>
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/>
<waitForPageLoad time="30" stepKey="waitForPageLoad10"/>

<actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/>

<!-- Checking the correctness of displayed custom options for user parameters on Order -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
<fillField selector="{{AdminOrdersGridSection.search}}" userInput="{$grabOrderNumber}" stepKey="fillOrderNum"/>
<click selector="{{AdminOrdersGridSection.submitSearch}}" stepKey="submitSearchOrderNum"/>
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappearOnSearch"/>
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/>
<waitForPageLoad stepKey="waitForOrderPageToLoad"/>

<actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/>

<!-- Checking the correctness of displayed custom options for user parameters on Order -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@
<click selector="{{AdminOrdersGridSection.submitSearch}}" stepKey="submitSearch"/>
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask4"/>

<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/>
<waitForPageLoad stepKey="waitForOrderPageToLoad"/>
<actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/>
<click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoice"/>
<waitForPageLoad stepKey="waitForNewInvoicePageToLoad"/>
<click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="clickSubmitInvoice"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
<actionGroup ref="FilterOrderGridByIdActionGroup" stepKey="filterOrderById">
<argument name="orderId" value="$grabOrderNumber"/>
</actionGroup>
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/>
<waitForPageLoad stepKey="waitForAdminOrderPageLoad"/>

<actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/>
<scrollTo selector="{{AdminOrderTotalSection.grandTotal}}" stepKey="scrollToOrderTotalSection"/>
<see selector="{{AdminOrderTotalSection.grandTotal}}" userInput="$$createProduct.price$$" stepKey="checkTotal"/>
</test>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
<fillField selector="{{AdminOrdersGridSection.search}}" userInput="{$grabOrderNumber}" stepKey="fillOrderNum"/>
<click selector="{{AdminOrdersGridSection.submitSearch}}" stepKey="submitSearchOrderNum"/>
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappearOnSearch"/>
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/>
<waitForPageLoad stepKey="waitForOrderPageToLoad"/>
<actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/>
<see selector="{{AdminOrderDetailsInformationSection.orderStatus}}" userInput="Pending" stepKey="seeAdminOrderStatus"/>
<see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="{{CustomerEntityOne.fullname}}" stepKey="seeAdminOrderGuest"/>
<see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="{{CustomerEntityOne.email}}" stepKey="seeAdminOrderEmail"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
<actionGroup ref="FilterOrderGridByIdActionGroup" stepKey="filterOrderGridById">
<argument name="orderId" value="$grabOrderNumber"/>
</actionGroup>
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/>
<waitForPageLoad stepKey="waitForCreatedOrderPageOpened"/>

<actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/>

<!--Verify that Created order is in Processing status-->
<see selector="{{AdminShipmentOrderInformationSection.orderStatus}}" userInput="Processing" stepKey="seeShipmentOrderStatus"/>
Expand Down
18 changes: 16 additions & 2 deletions app/code/Magento/Config/App/Config/Source/RuntimeConfigSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
use Magento\Framework\App\Config\ConfigSourceInterface;
use Magento\Framework\App\Config\ScopeCodeResolver;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\DataObject;
use Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory;
use Magento\Framework\App\Config\Scope\Converter;
use Magento\Framework\DB\Adapter\TableNotFoundException;

/**
* Class for retrieving runtime configuration from database.
Expand All @@ -34,20 +37,27 @@ class RuntimeConfigSource implements ConfigSourceInterface
* @var ScopeCodeResolver
*/
private $scopeCodeResolver;
/**
* @var DeploymentConfig
*/
private $deploymentConfig;

/**
* @param CollectionFactory $collectionFactory
* @param ScopeCodeResolver $scopeCodeResolver
* @param Converter $converter
* @param DeploymentConfig|null $deploymentConfig
*/
public function __construct(
CollectionFactory $collectionFactory,
ScopeCodeResolver $scopeCodeResolver,
Converter $converter
Converter $converter,
?DeploymentConfig $deploymentConfig = null
) {
$this->collectionFactory = $collectionFactory;
$this->converter = $converter;
$this->scopeCodeResolver = $scopeCodeResolver;
$this->deploymentConfig = $deploymentConfig ?? ObjectManager::getInstance()->get(DeploymentConfig::class);
}

/**
Expand All @@ -59,7 +69,7 @@ public function __construct(
*/
public function get($path = '')
{
$data = new DataObject($this->loadConfig());
$data = new DataObject($this->deploymentConfig->isDbAvailable() ? $this->loadConfig() : []);
return $data->getData($path) ?: [];
}

Expand All @@ -75,8 +85,12 @@ private function loadConfig()
{
try {
$collection = $this->collectionFactory->create();
$collection->load();
} catch (\DomainException $e) {
$collection = [];
} catch (TableNotFoundException $exception) {
// database is empty or not setup
$collection = [];
}
$config = [];
foreach ($collection as $item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,57 @@
*/
namespace Magento\Config\Test\Unit\App\Config\Source;

use ArrayIterator;
use Magento\Config\App\Config\Source\RuntimeConfigSource;
use Magento\Config\Model\ResourceModel\Config\Data\Collection;
use Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory;
use Magento\Framework\App\Config\Scope\Converter;
use Magento\Framework\App\Config\ScopeCodeResolver;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Config\Value;
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\DB\Adapter\TableNotFoundException;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* Test Class for retrieving runtime configuration from database.
* @package Magento\Config\Test\Unit\App\Config\Source
*/
class RuntimeConfigSourceTest extends \PHPUnit\Framework\TestCase
class RuntimeConfigSourceTest extends TestCase
{
/**
* @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
* @var CollectionFactory|MockObject
*/
private $collectionFactory;

/**
* @var ScopeCodeResolver|\PHPUnit_Framework_MockObject_MockObject
* @var ScopeCodeResolver|MockObject
*/
private $scopeCodeResolver;

/**
* @var Converter|\PHPUnit_Framework_MockObject_MockObject
* @var Converter|MockObject
*/
private $converter;

/**
* @var Value|\PHPUnit_Framework_MockObject_MockObject
* @var Value|MockObject
*/
private $configItem;

/**
* @var Value|\PHPUnit_Framework_MockObject_MockObject
* @var Value|MockObject
*/
private $configItemTwo;

/**
* @var RuntimeConfigSource
*/
private $configSource;
/**
* @var DeploymentConfig|MockObject
*/
private $deploymentConfig;

public function setUp()
{
Expand All @@ -68,20 +77,29 @@ public function setUp()
->disableOriginalConstructor()
->setMethods(['getScope', 'getPath', 'getValue', 'getScopeId'])
->getMock();
$this->deploymentConfig = $this->createPartialMock(DeploymentConfig::class, ['isDbAvailable']);
$this->configSource = new RuntimeConfigSource(
$this->collectionFactory,
$this->scopeCodeResolver,
$this->converter
$this->converter,
$this->deploymentConfig
);
}

public function testGet()
{
$this->deploymentConfig->method('isDbAvailable')
->willReturn(true);
$collection = $this->createPartialMock(Collection::class, ['load', 'getIterator']);
$collection->method('load')
->willReturn($collection);
$collection->method('getIterator')
->willReturn(new ArrayIterator([$this->configItem, $this->configItemTwo]));
$scope = 'websites';
$scopeCode = 'myWebsites';
$this->collectionFactory->expects($this->once())
->method('create')
->willReturn([$this->configItem, $this->configItemTwo]);
->willReturn($collection);
$this->configItem->expects($this->exactly(2))
->method('getScope')
->willReturn(ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
Expand Down Expand Up @@ -133,4 +151,22 @@ public function testGet()
$this->configSource->get()
);
}

public function testGetWhenDbIsNotAvailable()
{
$this->deploymentConfig->method('isDbAvailable')->willReturn(false);
$this->assertEquals([], $this->configSource->get());
}

public function testGetWhenDbIsEmpty()
{
$this->deploymentConfig->method('isDbAvailable')
->willReturn(true);
$collection = $this->createPartialMock(Collection::class, ['load']);
$collection->method('load')
->willThrowException($this->createMock(TableNotFoundException::class));
$this->collectionFactory->method('create')
->willReturn($collection);
$this->assertEquals([], $this->configSource->get());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@
<argument name="orderId" value="$grabOrderNumber"/>
</actionGroup>

<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/>
<waitForPageLoad stepKey="waitForOrderPageToLoad"/>
<actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/>
<click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceButton"/>
<waitForPageLoad stepKey="waitForNewInvoicePageLoad"/>
<fillField selector="{{AdminInvoiceItemsSection.qtyToInvoiceColumn}}" userInput="1" stepKey="ChangeQtyToInvoice"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<actionGroup ref="SearchAdminDataGridByKeywordActionGroup" stepKey="searchOrder">
<argument name="keyword" value="$grabOrderNumber"/>
</actionGroup>
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/>
<actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/>
<!--Create Invoice-->
<actionGroup ref="AdminCreateInvoiceActionGroup" stepKey="createInvoice"/>
<!--Create shipping label-->
Expand Down
Loading

0 comments on commit 6ee27c1

Please sign in to comment.