Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.4-develop' into refactor/mftf-…
Browse files Browse the repository at this point in the history
…shipping
  • Loading branch information
lbajsarowicz committed Jan 15, 2020
2 parents 22b2284 + 3a55648 commit 4b5defd
Show file tree
Hide file tree
Showing 34 changed files with 789 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
use Magento\Eav\Api\Data\AttributeGroupInterfaceFactory;
use Magento\Eav\Api\Data\AttributeInterface;
use Magento\Eav\Api\Data\AttributeSetInterface;
use Magento\Eav\Model\Cache\Type as CacheType;
use Magento\Framework\Api\ExtensionAttributesFactory;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\App\CacheInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Controller\Result\Json;
use Magento\Framework\Controller\Result\JsonFactory;
Expand All @@ -29,7 +31,7 @@
use Psr\Log\LoggerInterface;

/**
* Class AddAttributeToTemplate
* Assign attribute to attribute set.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
Expand Down Expand Up @@ -80,6 +82,11 @@ class AddAttributeToTemplate extends Product implements HttpPostActionInterface
*/
protected $extensionAttributesFactory;

/**
* @var CacheInterface
*/
private $cache;

/**
* Constructor
*
Expand All @@ -94,8 +101,8 @@ class AddAttributeToTemplate extends Product implements HttpPostActionInterface
* @param AttributeManagementInterface $attributeManagement
* @param LoggerInterface $logger
* @param ExtensionAttributesFactory $extensionAttributesFactory
* @param CacheInterface|null $cache
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @SuppressWarnings(PHPMD.LongVariable)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function __construct(
Expand All @@ -109,7 +116,8 @@ public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder = null,
AttributeManagementInterface $attributeManagement = null,
LoggerInterface $logger = null,
ExtensionAttributesFactory $extensionAttributesFactory = null
ExtensionAttributesFactory $extensionAttributesFactory = null,
CacheInterface $cache = null
) {
parent::__construct($context, $productBuilder);
$this->resultJsonFactory = $resultJsonFactory;
Expand All @@ -129,6 +137,7 @@ public function __construct(
->get(LoggerInterface::class);
$this->extensionAttributesFactory = $extensionAttributesFactory ?: ObjectManager::getInstance()
->get(ExtensionAttributesFactory::class);
$this->cache = $cache ?? ObjectManager::getInstance()->get(CacheInterface::class);
}

/**
Expand Down Expand Up @@ -203,6 +212,7 @@ function (AttributeInterface $attribute) use ($attributeSet, $attributeGroup) {
);
}
);
$this->cache->clean([CacheType::CACHE_TAG]);
} catch (LocalizedException $e) {
$response->setError(true);
$response->setMessage($e->getMessage());
Expand All @@ -223,7 +233,7 @@ function (AttributeInterface $attribute) use ($attributeSet, $attributeGroup) {
*/
private function getBasicAttributeSearchCriteriaBuilder()
{
$attributeIds = (array) $this->getRequest()->getParam('attributeIds', []);
$attributeIds = (array)$this->getRequest()->getParam('attributeIds', []);

if (empty($attributeIds['selected'])) {
throw new LocalizedException(__('Attributes were missing and must be specified.'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ protected function populateFlatTables(array $stores)
}
$category['store_id'] = $store->getId();
$data[] = $this->prepareValuesToInsert(
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
array_merge($category, $attributesData[$category[$linkField]])
);
}
Expand Down Expand Up @@ -183,7 +184,7 @@ private function getActualStoreTablesForCategoryFlat(): array
foreach ($this->storeManager->getStores() as $store) {
$actualStoreTables[] = sprintf(
'%s_store_%s',
$this->connection->getTableName('catalog_category_flat'),
$this->connection->getTableName($this->getTableName('catalog_category_flat')),
$store->getId()
);
}
Expand All @@ -199,7 +200,7 @@ private function getActualStoreTablesForCategoryFlat(): array
private function deleteAbandonedStoreCategoryFlatTables(): void
{
$existentTables = $this->connection->getTables(
$this->connection->getTableName('catalog_category_flat_store_%')
$this->connection->getTableName($this->getTableName('catalog_category_flat_store_%'))
);
$actualStoreTables = $this->getActualStoreTablesForCategoryFlat();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected function _updateRelationProducts($storeId, $productIds = null)
['t' => $this->_productIndexerHelper->getTable($relation->getTable())],
['entity_table.entity_id', $relation->getChildFieldName(), new \Zend_Db_Expr('1')]
)->join(
['entity_table' => $this->_connection->getTableName('catalog_product_entity')],
['entity_table' => $this->_productIndexerHelper->getTable('catalog_product_entity')],
"entity_table.{$metadata->getLinkField()} = t.{$relation->getParentFieldName()}",
[]
)->join(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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="AdminExpandProductAttributesTabActionGroup">
<annotations>
<description>Expands the 'Attributes' tab on the Admin Product page.</description>
</annotations>

<scrollTo selector="{{AdminProductAttributeSection.attributeSectionHeader}}" stepKey="scrollToAttributesTab"/>
<conditionalClick selector="{{AdminProductAttributeSection.attributeSectionHeader}}" dependentSelector="{{AdminProductAttributeSection.attributeSection}}" visible="false" stepKey="expandAttributesTab"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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="AssertStorefrontAttributeOptionPresentInLayeredNavigationActionGroup">
<annotations>
<description>Clicks on the attribute label. Checks for attribute option presence.</description>
</annotations>
<arguments>
<argument name="attributeLabel" type="string" defaultValue="{{ProductAttributeFrontendLabel.label}}"/>
<argument name="attributeOptionLabel" type="string" defaultValue="{{Option1Store0.label}}"/>
<argument name="attributeOptionPosition" type="string" defaultValue="1"/>
</arguments>

<waitForElementVisible selector="{{StorefrontCategorySidebarSection.filterOptionsTitle(attributeLabel)}}" stepKey="waitForAttributeVisible"/>
<conditionalClick selector="{{StorefrontCategorySidebarSection.filterOptionsTitle(attributeLabel)}}" dependentSelector="{{StorefrontCategorySidebarSection.activeFilterOptions}}" visible="false" stepKey="clickToExpandAttribute"/>
<waitForElementVisible selector="{{StorefrontCategorySidebarSection.activeFilterOptions}}" stepKey="waitForAttributeOptionsVisible"/>
<see selector="{{StorefrontCategorySidebarSection.activeFilterOptionItemByPosition(attributeOptionPosition)}}" userInput="{{attributeOptionLabel}}" stepKey="assertAttributeOptionInLayeredNavigation"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
<element name="optionQty" type="text" selector=".filter-options-content .item .count"/>
<element name="filterOptionByLabel" type="button" selector=" div.filter-options-item div[option-label='{{optionLabel}}']" parameterized="true"/>
<element name="removeFilter" type="button" selector="div.filter-current .remove"/>
<element name="activeFilterOptions" type="text" selector=".filter-options-item.active .items"/>
<element name="activeFilterOptionItemByPosition" type="text" selector=".filter-options-item.active .items li:nth-child({{itemPosition}}) a" parameterized="true"/>
</section>
<section name="StorefrontCategorySidebarMobileSection">
<element name="shopByButton" type="button" selector="//div[contains(@class, 'filter-title')]/strong[contains(text(), 'Shop By')]"/>
</section>
</sections>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?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="AdminCheckCustomAttributeValuesAfterProductSaveTest">
<annotations>
<features value="Catalog"/>
<stories value="Product attributes"/>
<title value="Saving custom attribute values using UI"/>
<description value="Checks that saved custom attribute values are reflected on the product's edit page"/>
<severity value="MAJOR"/>
<testCaseId value="MC-29653"/>
<useCaseId value="MC-29023"/>
<group value="catalog"/>
</annotations>
<before>
<!-- Create multi select product attribute -->
<createData entity="productAttributeMultiselectTwoOptions" stepKey="createMultiSelectProductAttribute"/>
<!-- Add options to created product attribute -->
<createData entity="productAttributeOption1" stepKey="addFirstOptionToAttribute">
<requiredEntity createDataKey="createMultiSelectProductAttribute"/>
</createData>
<createData entity="productAttributeOption2" stepKey="addSecondOptionToAttribute">
<requiredEntity createDataKey="createMultiSelectProductAttribute"/>
</createData>
<createData entity="productAttributeOption3" stepKey="addThirdOptionToAttribute">
<requiredEntity createDataKey="createMultiSelectProductAttribute"/>
</createData>
<!-- Create simple product -->
<createData entity="SimpleProduct2" stepKey="createSimpleProduct"/>
<magentoCLI command="indexer:reindex" arguments="catalogsearch_fulltext" stepKey="reindexCatalogSearch"/>
<!-- Login to Admin page -->
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
</before>
<after>
<!-- Delete created entities -->
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
<deleteData createDataKey="createMultiSelectProductAttribute" stepKey="deleteMultiSelectProductAttribute"/>
<!-- Logout from Admin page -->
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
</after>

<!-- Open created product for edit -->
<amOnPage url="{{AdminProductEditPage.url($createSimpleProduct.id$)}}" stepKey="goToProductEditPage"/>
<waitForPageLoad stepKey="waitForProductPageLoad"/>

<!-- Add created attribute to the product -->
<actionGroup ref="AddProductAttributeInProductModalActionGroup" stepKey="addAttributeToProduct">
<argument name="attributeCode" value="$createMultiSelectProductAttribute.attribute_code$"/>
</actionGroup>
<waitForPageLoad stepKey="waitForAttributeAdded"/>

<!-- Expand 'Attributes' tab -->
<actionGroup ref="AdminExpandProductAttributesTabActionGroup" stepKey="expandAttributesTab"/>
<!-- Check created attribute presents in the 'Attributes' tab -->
<seeElement selector="{{AdminProductAttributesSection.attributeDropdownByCode($createMultiSelectProductAttribute.attribute_code$)}}" stepKey="assertAttributeIsPresentInTab"/>
<!-- Select attribute options -->
<selectOption selector="{{AdminProductAttributesSection.attributeDropdownByCode($createMultiSelectProductAttribute.attribute_code$)}}" parameterArray="[$addFirstOptionToAttribute.option[store_labels][0][label]$, $addThirdOptionToAttribute.option[store_labels][0][label]$]" stepKey="selectAttributeOptions"/>
<!-- Save product -->
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProductForm"/>

<!-- Check attribute options are selected -->
<actionGroup ref="AdminExpandProductAttributesTabActionGroup" stepKey="expandAttributesTabAfterProductSave"/>
<seeOptionIsSelected selector="{{AdminProductAttributesSection.attributeDropdownByCode($createMultiSelectProductAttribute.attribute_code$)}}" userInput="$addFirstOptionToAttribute.option[store_labels][0][label]$" stepKey="assertFirstOptionIsSelected"/>
<seeOptionIsSelected selector="{{AdminProductAttributesSection.attributeDropdownByCode($createMultiSelectProductAttribute.attribute_code$)}}" userInput="$addThirdOptionToAttribute.option[store_labels][0][label]$" stepKey="assertThirdOptionIsSelected"/>

<!-- Search for the product on Storefront -->
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToHomePage"/>
<waitForPageLoad stepKey="waitForHomePageLoad"/>
<actionGroup ref="StorefrontCheckQuickSearchActionGroup" stepKey="searchProductOnStorefront">
<argument name="phrase" value="$createSimpleProduct.name$"/>
</actionGroup>

<!-- Assert that attribute values present in layered navigation -->
<actionGroup ref="AssertStorefrontAttributeOptionPresentInLayeredNavigationActionGroup" stepKey="assertFirstAttributeOptionPresence">
<argument name="attributeLabel" value="$createMultiSelectProductAttribute.attribute[frontend_labels][0][label]$"/>
<argument name="attributeOptionLabel" value="$addFirstOptionToAttribute.option[store_labels][0][label]$"/>
<argument name="attributeOptionPosition" value="1"/>
</actionGroup>
<actionGroup ref="AssertStorefrontAttributeOptionPresentInLayeredNavigationActionGroup" stepKey="assertThirdAttributeOptionPresence">
<argument name="attributeLabel" value="$createMultiSelectProductAttribute.attribute[frontend_labels][0][label]$"/>
<argument name="attributeOptionLabel" value="$addThirdOptionToAttribute.option[store_labels][0][label]$"/>
<argument name="attributeOptionPosition" value="2"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<actionGroup ref="logout" stepKey="adminLogout"/>
</after>

<actionGroup ref="DisabledWYSIWYGActionGroup" stepKey="disableWYSIWYG"/>
<comment userInput="remove me" stepKey="disableWYSIWYG"/>

<!-- Create new virtual product -->
<actionGroup ref="GoToSpecifiedCreateProductPageActionGroup" stepKey="createVirtualProduct">
Expand Down Expand Up @@ -185,6 +185,6 @@
<actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openCart"/>
<dontSeeElement selector="{{StorefrontProductCartGiftOptionSection.giftOptions}}" stepKey="dontSeeGiftOptionBtn"/>

<actionGroup ref="EnabledWYSIWYGActionGroup" stepKey="enableWYSIWYG"/>
<comment userInput="remove me" stepKey="enableWYSIWYG"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<testCaseId value="MC-14714"/>
<severity value="CRITICAL"/>
<group value="mtf_migrated"/>
<skip>
<issueId value="MC-30409"/>
</skip>
</annotations>

<before>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
<testCaseId value="MAGETWO-58718"/>
<group value="product"/>
<group value="WYSIWYGDisabled"/>
<skip>
<issueId value="MC-13841"/>
</skip>
</annotations>
<before>
<!-- Login Admin -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<severity value="CRITICAL"/>
<testCaseId value="MC-79"/>
<group value="CatalogRule"/>
<skip>
<issueId value="MC-30384"/>
</skip>
</annotations>
<before>
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<severity value="CRITICAL"/>
<testCaseId value="MC-5922"/>
<group value="checkout"/>
<skip>
<issueId value="MC-30111"/>
</skip>
</annotations>
<before>
<createData entity="SimpleSubCategory" stepKey="simplecategory"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<seeElement selector="{{StorefrontCMSPageSection.mediaDescription}}" stepKey="assertMediaDescription"/>
<seeElementInDOM selector="{{StorefrontCMSPageSection.imageSource(ImageUpload3.fileName)}}" stepKey="assertMediaSource"/>
<after>
<actionGroup ref="DisabledWYSIWYGActionGroup" stepKey="disableWYSIWYGFirst"/>
<deleteData createDataKey="createCMSPage" stepKey="deletePreReqCMSPage" />
<actionGroup ref="DisabledWYSIWYGActionGroup" stepKey="disableWYSIWYG"/>
<actionGroup ref="logout" stepKey="logout"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public function execute(int $customerId): array
{
$connection = $this->resourceConnection->getConnection();
$allowedItemsStatuses = [Item::LINK_STATUS_PENDING_PAYMENT, Item::LINK_STATUS_PAYMENT_REVIEW];
$downloadablePurchasedTable = $connection->getTableName('downloadable_link_purchased');
$downloadablePurchasedTable = $this->resourceConnection->getTableName('downloadable_link_purchased');

/* The fields names are hardcoded since there's no existing name reference in the code */
$selectQuery = $connection->select()
->from($downloadablePurchasedTable)
->joinLeft(
['item' => $connection->getTableName('downloadable_link_purchased_item')],
['item' => $this->resourceConnection->getTableName('downloadable_link_purchased_item')],
"$downloadablePurchasedTable.purchased_id = item.purchased_id"
)
->where("$downloadablePurchasedTable.customer_id = ?", $customerId)
Expand Down
Loading

0 comments on commit 4b5defd

Please sign in to comment.