Skip to content

Commit

Permalink
Merge pull request magento#4398 from magento-epam/EPAM-PR-59
Browse files Browse the repository at this point in the history
- fixed "[GitHub] catalog:images:resize = getimagesize(): Read error! in vendor/magento/module-catalog/Model/Product/Image.php on line 410 if an image is 0 bytes magento#8204"
- fixed "CMS page of the second website with same URL key as first website, show content of the First website instead of second website content."
- fixed "Error appears when a restricted user tries to add a new category from the product page"
- fixed "Product attribute cannot be edited if the attribute was created with 2 same values"
- fixed "Invalid join condition in Product Flat Indexer"
- fixed "Fatal error on Import/Export page if deleted category ids exist in category path"
  • Loading branch information
irenelagno authored Jun 24, 2019
2 parents 1e58f70 + f531148 commit c7c66ad
Show file tree
Hide file tree
Showing 38 changed files with 1,303 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,4 @@
<waitForPageLoad stepKey="waitForSaveUser" time="10"/>
<see userInput="You saved the user." stepKey="seeSuccessMessage" />
</actionGroup>

<!--Delete User-->
<actionGroup name="AdminDeleteNewUserActionGroup">

<click stepKey="clickOnUser" selector="{{AdminDeleteUserSection.theUser}}"/>
<fillField stepKey="TypeCurrentPassword" selector="{{AdminDeleteUserSection.password}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/>
<scrollToTopOfPage stepKey="scrollToTop"/>
<click stepKey="clickToDeleteUser" selector="{{AdminDeleteUserSection.delete}}"/>
<waitForPageLoad stepKey="waitForDeletePopupOpen" time="5"/>
<click stepKey="clickToConfirm" selector="{{AdminDeleteUserSection.confirm}}"/>
<waitForPageLoad stepKey="waitForPageLoad" time="10"/>
<see userInput="You deleted the user." stepKey="seeSuccessMessage" />
</actionGroup>

</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ protected function _reindex($storeId, array $changedIds = [])
}

/**
* Retrieve Product Type Instances
* as key - type code, value - instance model
* Retrieve Product Type Instances as key - type code, value - instance model
*
* @return array
*/
Expand Down Expand Up @@ -213,17 +212,19 @@ protected function _updateRelationProducts($storeId, $productIds = null)
) {
$columns = $this->_productIndexerHelper->getFlatColumns();
$fieldList = array_keys($columns);
unset($columns['entity_id']);
unset($columns['child_id']);
unset($columns['is_child']);
unset(
$columns['entity_id'],
$columns['child_id'],
$columns['is_child']
);
/** @var $select \Magento\Framework\DB\Select */
$select = $this->_connection->select()->from(
['t' => $this->_productIndexerHelper->getTable($relation->getTable())],
[$relation->getChildFieldName(), new \Zend_Db_Expr('1')]
['entity_table.entity_id', $relation->getChildFieldName(), new \Zend_Db_Expr('1')]
)->join(
['entity_table' => $this->_connection->getTableName('catalog_product_entity')],
'entity_table.' . $metadata->getLinkField() . 't.' . $relation->getParentFieldName(),
[$relation->getParentFieldName() => 'entity_table.entity_id']
"entity_table.{$metadata->getLinkField()} = t.{$relation->getParentFieldName()}",
[]
)->join(
['e' => $this->_productIndexerHelper->getFlatTableName($storeId)],
"e.entity_id = t.{$relation->getChildFieldName()}",
Expand All @@ -232,10 +233,10 @@ protected function _updateRelationProducts($storeId, $productIds = null)
if ($relation->getWhere() !== null) {
$select->where($relation->getWhere());
}
if ($productIds !== null) {
if (!empty($productIds)) {
$cond = [
$this->_connection->quoteInto("{$relation->getChildFieldName()} IN(?)", $productIds),
$this->_connection->quoteInto("entity_table.entity_id IN(?)", $productIds),
$this->_connection->quoteInto('entity_table.entity_id IN(?)', $productIds),
];

$select->where(implode(' OR ', $cond));
Expand Down Expand Up @@ -273,15 +274,11 @@ protected function _cleanRelationProducts($storeId)
$select = $this->_connection->select()->distinct(
true
)->from(
['t' => $this->_productIndexerHelper->getTable($relation->getTable())],
[]
)->join(
['entity_table' => $this->_connection->getTableName('catalog_product_entity')],
'entity_table.' . $metadata->getLinkField() . 't.' . $relation->getParentFieldName(),
[$relation->getParentFieldName() => 'entity_table.entity_id']
$this->_productIndexerHelper->getTable($relation->getTable()),
$relation->getParentFieldName()
);
$joinLeftCond = [
"e.entity_id = entity_table.entity_id",
"e.{$metadata->getLinkField()} = t.{$relation->getParentFieldName()}",
"e.child_id = t.{$relation->getChildFieldName()}",
];
if ($relation->getWhere() !== null) {
Expand All @@ -302,7 +299,7 @@ protected function _cleanRelationProducts($storeId)
'e.is_child = ?',
1
)->where(
'e.entity_id IN(?)',
"e.{$metadata->getLinkField()} IN(?)",
$entitySelect
)->where(
"t.{$relation->getChildFieldName()} IS NULL"
Expand Down Expand Up @@ -335,6 +332,8 @@ protected function _isFlatTableExists($storeId)
}

/**
* Get Metadata Pool
*
* @return \Magento\Framework\EntityManager\MetadataPool
*/
private function getMetadataPool()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,15 @@
</arguments>
<searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="[{{categoryName}}]" stepKey="searchAndSelectCategory"/>
</actionGroup>
<!--Remove category from product in ProductFrom Page-->
<actionGroup name="removeCategoryFromProduct">
<arguments>
<argument name="categoryName" type="string" defaultValue="{{_defaultCategory.name}}"/>
</arguments>
<click selector="{{AdminProductFormSection.categoriesDropdown}}" stepKey="clickCategoriesDropDown"/>
<click selector="{{AdminProductFormSection.unselectCategories(categoryName)}}" stepKey="unselectCategories"/>
<click selector="{{AdminProductFormSection.done}}" stepKey="clickOnDoneAdvancedCategory"/>
</actionGroup>

<actionGroup name="expandAdminProductSection">
<arguments>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<element name="selectMultipleCategories" type="input" selector="//*[@data-index='container_category_ids']//*[contains(@class, '_selected')]"/>
<element name="countryOfManufacture" type="select" selector="select[name='product[country_of_manufacture]']"/>
<element name="newAddedAttribute" type="text" selector="//fieldset[@class='admin__fieldset']//div[contains(@data-index,'{{attributeCode}}')]" parameterized="true"/>
<element name="newCategoryButton" type="button" selector="button[data-index='create_category_button']" timeout="30"/>
<element name="footerBlock" type="block" selector="//footer"/>
</section>
<section name="ProductInWebsitesSection">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?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="AdminRestrictedUserAddCategoryFromProductPageTest">
<annotations>
<features value="Catalog"/>
<title value="Adding new category from product page by restricted user"/>
<description value="Adding new category from product page by restricted user"/>
<severity value="MAJOR"/>
<testCaseId value="MC-17229"/>
<useCaseId value="MAGETWO-69893"/>
<group value="catalog"/>
</annotations>
<before>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
<!--Create category-->
<comment userInput="Create category" stepKey="commentCreateCategory"/>
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
</before>
<after>
<!--Delete created product-->
<comment userInput="Delete created product" stepKey="commentDeleteProduct"/>
<actionGroup ref="deleteProductBySku" stepKey="deleteProduct">
<argument name="sku" value="{{_defaultProduct.sku}}"/>
</actionGroup>
<actionGroup ref="resetProductGridToDefaultView" stepKey="resetFiltersIfExist"/>
<actionGroup ref="logout" stepKey="logoutOfUser"/>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
<!--Delete created data-->
<comment userInput="Delete created data" stepKey="commentDeleteCreatedData"/>
<amOnPage url="{{AdminRolesPage.url}}" stepKey="navigateToUserRoleGrid" />
<waitForPageLoad stepKey="waitForRolesGridLoad" />
<actionGroup ref="AdminDeleteRoleActionGroup" stepKey="deleteUserRole">
<argument name="role" value="adminRole"/>
</actionGroup>
<amOnPage url="{{AdminUsersPage.url}}" stepKey="goToAllUsersPage"/>
<waitForPageLoad stepKey="waitForUsersGridLoad" />
<actionGroup ref="AdminDeleteNewUserActionGroup" stepKey="deleteUser">
<argument name="userName" value="{{admin2.username}}"/>
</actionGroup>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
</after>
<!--Create user role-->
<comment userInput="Create user role" stepKey="commentCreateUserRole"/>
<actionGroup ref="AdminFillUserRoleRequiredData" stepKey="fillUserRoleRequiredData">
<argument name="User" value="adminRole"/>
<argument name="restrictedRole" value="Stores"/>
</actionGroup>
<click selector="{{AdminEditRoleInfoSection.roleResourcesTab}}" stepKey="clickRoleResourcesTab" />
<actionGroup ref="AdminAddRestrictedRole" stepKey="addRestrictedRoleStores">
<argument name="User" value="adminRole"/>
<argument name="restrictedRole" value="Stores"/>
</actionGroup>
<actionGroup ref="AdminAddRestrictedRole" stepKey="addRestrictedRoleProducts">
<argument name="User" value="adminRole"/>
<argument name="restrictedRole" value="Products"/>
</actionGroup>
<click selector="{{AdminEditRoleInfoSection.saveButton}}" stepKey="clickSaveRoleButton" />
<see userInput="You saved the role." stepKey="seeUserRoleSavedMessage"/>
<!--Create user and assign role to it-->
<comment userInput="Create user and assign role to it" stepKey="commentCreateUser"/>
<actionGroup ref="AdminCreateUserActionGroup" stepKey="createAdminUser">
<argument name="role" value="adminRole"/>
<argument name="User" value="admin2"/>
</actionGroup>
<!--Log out of admin and login with newly created user-->
<comment userInput="Log out of admin and login with newly created user" stepKey="commentLoginWithNewUser"/>
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsNewUser">
<argument name="adminUser" value="admin2"/>
</actionGroup>
<!--Go to create product page-->
<comment userInput="Go to create product page" stepKey="commentGoCreateProductPage"/>
<actionGroup ref="goToCreateProductPage" stepKey="goToCreateProductPage"/>
<dontSeeElement selector="{{AdminProductFormSection.newCategoryButton}}" stepKey="dontSeeNewCategoryButton"/>
<!--Fill product data and assign to category-->
<comment userInput="Fill product data and assign to category" stepKey="commentFillProductData"/>
<actionGroup ref="fillMainProductForm" stepKey="fillMainProductForm"/>
<actionGroup ref="SetCategoryByName" stepKey="addCategoryToProduct">
<argument name="categoryName" value="$$createCategory.name$$"/>
</actionGroup>
<actionGroup ref="saveProductForm" stepKey="saveProduct"/>
<!--Assert that category exist in field-->
<comment userInput="Assert that category exist in field" stepKey="commentAssertion"/>
<grabTextFrom selector="{{AdminProductFormSection.categoriesDropdown}}" stepKey="grabCategoryName"/>
<assertContains stepKey="assertThatCategory">
<expectedResult type="variable">$$createCategory.name$$</expectedResult>
<actualResult type="variable">$grabCategoryName</actualResult>
</assertContains>
<!--Remove the category from the product and assert that it removed-->
<comment userInput="Remove the category from the product and assert that it removed" stepKey="assertCategoryRemoved"/>
<actionGroup ref="removeCategoryFromProduct" stepKey="removeCategoryFromProduct">
<argument name="categoryName" value="$$createCategory.name$$"/>
</actionGroup>
<actionGroup ref="saveProductForm" stepKey="saveProductAfterRemovingCategory"/>
<grabTextFrom selector="{{AdminProductFormSection.categoriesDropdown}}" stepKey="grabCategoryFieldContent"/>
<assertNotContains stepKey="assertThatCategoryRemoved">
<expectedResult type="variable">$$createCategory.name$$</expectedResult>
<actualResult type="variable">$grabCategoryFieldContent</actualResult>
</assertNotContains>
</test>
</tests>
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\Test\Unit\Ui\DataProvider\Product\Form\Modifier;

use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Categories;
Expand All @@ -12,6 +14,7 @@
use Magento\Framework\DB\Helper as DbHelper;
use Magento\Framework\UrlInterface;
use Magento\Store\Model\Store;
use Magento\Framework\AuthorizationInterface;

/**
* Class CategoriesTest
Expand Down Expand Up @@ -45,6 +48,11 @@ class CategoriesTest extends AbstractModifierTest
*/
protected $categoryCollectionMock;

/**
* @var AuthorizationInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $authorizationMock;

protected function setUp()
{
parent::setUp();
Expand All @@ -63,6 +71,9 @@ protected function setUp()
$this->categoryCollectionMock = $this->getMockBuilder(CategoryCollection::class)
->disableOriginalConstructor()
->getMock();
$this->authorizationMock = $this->getMockBuilder(AuthorizationInterface::class)
->disableOriginalConstructor()
->getMock();

$this->categoryCollectionFactoryMock->expects($this->any())
->method('create')
Expand All @@ -86,11 +97,15 @@ protected function setUp()
*/
protected function createModel()
{
return $this->objectManager->getObject(Categories::class, [
'locator' => $this->locatorMock,
'categoryCollectionFactory' => $this->categoryCollectionFactoryMock,
'arrayManager' => $this->arrayManagerMock,
]);
return $this->objectManager->getObject(
Categories::class,
[
'locator' => $this->locatorMock,
'categoryCollectionFactory' => $this->categoryCollectionFactoryMock,
'arrayManager' => $this->arrayManagerMock,
'authorization' => $this->authorizationMock
]
);
}

public function testModifyData()
Expand Down Expand Up @@ -130,7 +145,9 @@ public function testModifyMetaLocked($locked)
],
],
];

$this->authorizationMock->expects($this->exactly(2))
->method('isAllowed')
->willReturn(true);
$this->arrayManagerMock->expects($this->any())
->method('findPath')
->willReturn('path');
Expand Down
Loading

0 comments on commit c7c66ad

Please sign in to comment.