Skip to content

Commit

Permalink
Merge pull request magento#3518 from magento-tsg/2.2-develop-pr61
Browse files Browse the repository at this point in the history
[TSG] Backporting for 2.2 (pr61) (2.2.8)
  • Loading branch information
xmav authored Dec 10, 2018
2 parents b4269c2 + a70652f commit aa0c29d
Show file tree
Hide file tree
Showing 51 changed files with 1,233 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function getPositions(int $categoryId)
$categoryId
)->order(
'ccp.position ' . \Magento\Framework\DB\Select::SQL_ASC
)->order(
'ccp.product_id ' . \Magento\Framework\DB\Select::SQL_DESC
);

return array_flip($connection->fetchCol($select));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
<click selector="{{AdminProductAttributeGridSection.attributeCode(attributeCode)}}" stepKey="clickRowToEdit"/>
<waitForPageLoad stepKey="waitForColorAttributePageLoad"/>
</actionGroup>

<!--Save product attribute and see success message-->
<actionGroup name="SaveProductAttribute">
<scrollToTopOfPage stepKey="scrollToTop"/>
<click selector="{{AdminMainActionsSection.save}}" stepKey="clickSaveAttribute"/>
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the product attribute." stepKey="seeSuccessMessage"/>
</actionGroup>
<actionGroup name="deleteProductAttribute">
<arguments>
<argument name="ProductAttribute"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<arguments>
<argument name="attributeSetName" type="string"/>
</arguments>
<scrollToTopOfPage stepKey="scrollToTopOfPage"/>
<click selector="{{AdminProductFormSection.attributeSet}}" stepKey="startEditAttrSet"/>
<fillField selector="{{AdminProductFormSection.attributeSetFilter}}" userInput="{{attributeSetName}}" stepKey="searchForAttrSet"/>
<waitForAjaxLoad stepKey="waitForLoad"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<element name="productTierPriceValueTypeSelect" type="select" selector="[name='product[tier_price][{{var1}}][value_type]']" parameterized="true"/>
<element name="productTierPriceFixedPriceInput" type="input" selector="[name='product[tier_price][{{var1}}][price]']" parameterized="true"/>
<element name="productTierPricePercentageValuePriceInput" type="input" selector="[name='product[tier_price][{{var1}}][percentage_value]']" parameterized="true"/>
<element name="productTierPricePercentageError" type="text" selector="div[data-index='percentage_value'] label.admin__field-error" />
<element name="specialPrice" type="input" selector="input[name='product[special_price]']"/>
<element name="doneButton" type="button" selector=".product_form_product_form_advanced_pricing_modal button.action-primary" timeout="5"/>
</section>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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="AdminValidateApplyingTierPriceWithEmptyDiscountValueTest">
<annotations>
<features value="Apply tier price"/>
<title value="Apply Tier Price with empty discount value"/>
<description value="Validate applying tier price to product"/>
<stories value="Apply Tier Price with empty discount value" />
<severity value="CRITICAL"/>
<testCaseId value="MAGETWO-96484"/>
<group value="product"/>
</annotations>
<before>
<createData entity="_defaultCategory" stepKey="createCategory"/>
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
</before>
<after>
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/>
<actionGroup ref="AdminResetProductGridToDefaultViewActionGroup" stepKey="resetGridToDefaultKeywordSearch"/>
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
</after>

<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct">
<argument name="product" value="$$createSimpleProduct$$"/>
</actionGroup>
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProductPage">
<argument name="product" value="$$createSimpleProduct$$"/>
</actionGroup>
<scrollToTopOfPage stepKey="scrollToTopOfPage"/>
<click selector="{{AdminProductFormSection.advancedPricingLink}}" stepKey="clickOnAdvancedPricingButton"/>
<waitForElement selector="{{AdminProductFormAdvancedPricingSection.customerGroupPriceAddButton}}" stepKey="waitForCustomerGroupPriceAddButton"/>
<click selector="{{AdminProductFormAdvancedPricingSection.customerGroupPriceAddButton}}" stepKey="addCustomerGroupPrice"/>
<fillField selector="{{AdminProductFormAdvancedPricingSection.productTierPriceQtyInput('0')}}" userInput="1" stepKey="fillProductTierPriceQtyInput"/>
<selectOption selector="{{AdminProductFormAdvancedPricingSection.productTierPriceValueTypeSelect('0')}}" userInput="Discount" stepKey="selectProductTierPriceValueType"/>
<clearField selector="{{AdminProductFormAdvancedPricingSection.productTierPricePercentageValuePriceInput('0')}}" stepKey="clearPercentageValueField"/>
<click selector="{{AdminProductFormAdvancedPricingSection.doneButton}}" stepKey="clickDoneButton"/>
<see selector="{{AdminProductFormAdvancedPricingSection.productTierPricePercentageError}}" userInput="This is a required field." stepKey="assertPercentageError"/>
<fillField selector="{{AdminProductFormAdvancedPricingSection.productTierPricePercentageValuePriceInput('0')}}" userInput="10" stepKey="setPercentageValue"/>
<click selector="{{AdminProductFormAdvancedPricingSection.doneButton}}" stepKey="clickDoneButton1"/>
<dontSee selector="{{AdminProductFormAdvancedPricingSection.productTierPricePercentageError}}" userInput="This is a required field." stepKey="assertNoPercentageError"/>
<actionGroup ref="SaveProductOnProductPageOnAdmin" stepKey="saveProduct"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function testGetPositions()
$this->select->expects($this->once())
->method('where')
->willReturnSelf();
$this->select->expects($this->once())
$this->select->expects($this->exactly(2))
->method('order')
->willReturnSelf();
$this->select->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Listing\Collector;

use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\Data\ProductRender\ImageInterface;
use Magento\Catalog\Api\Data\ProductRenderInterface;
use Magento\Catalog\Helper\Image as ImageHelper;
use Magento\Catalog\Helper\ImageFactory;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Ui\DataProvider\Product\Listing\Collector\Image;
use Magento\Framework\View\DesignInterface;
use Magento\Framework\View\DesignLoader;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Catalog\Helper\ImageFactory;
use Magento\Catalog\Api\Data\ProductRender\ImageInterface;
use Magento\Catalog\Helper\Image as ImageHelper;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand Down Expand Up @@ -42,8 +43,21 @@ class ImageTest extends \PHPUnit\Framework\TestCase
/** @var \Magento\Catalog\Api\Data\ProductRender\ImageInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject */
private $imageInterfaceFactory;

/** @var DesignLoader|\PHPUnit_Framework_MockObject_MockObject */
private $designLoader;

/**
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
*/
protected $objectManager;

/**
* @inheritdoc
*/
public function setUp()
{
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);

$this->imageFactory = $this->getMockBuilder(ImageFactory::class)
->disableOriginalConstructor()
->getMock();
Expand All @@ -60,14 +74,21 @@ public function setUp()
->getMock();
$this->storeManager = $this->createMock(StoreManagerInterface::class);
$this->design = $this->createMock(DesignInterface::class);
$this->model = new Image(
$this->imageFactory,
$this->state,
$this->storeManager,
$this->design,
$this->imageInterfaceFactory,
$this->imageCodes
);
$this->designLoader = $this->createMock(DesignLoader::class);

$this->model = $this->objectManager
->getObject(
Image::class,
[
'imageFactory' => $this->imageFactory,
'state' => $this->state,
'storeManager' => $this->storeManager,
'design' => $this->design,
'imageRenderInfoFactory' => $this->imageInterfaceFactory,
'imageCodes' => $this->imageCodes,
'designLoader' => $this->designLoader,
]
);
}

public function testGet()
Expand Down Expand Up @@ -165,6 +186,7 @@ public function testEmulateImageCreating()
$imageMock->expects($this->once())
->method('setUrl')
->with('url');
$this->designLoader->expects($this->once())->method('load');

$this->assertEquals(
$imageHelperMock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
* @since 101.1.0
*/
public function modifyData(array $data)
Expand All @@ -54,8 +54,11 @@ public function modifyData(array $data)
}

/**
* {@inheritdoc}
* Add tier price info to meta array.
*
* @since 101.1.0
* @param array $meta
* @return array
*/
public function modifyMeta(array $meta)
{
Expand Down Expand Up @@ -150,8 +153,8 @@ private function getUpdatedTierPriceStructure(array $priceMeta)
'dataType' => Price::NAME,
'addbefore' => '%',
'validation' => [
'validate-number' => true,
'less-than-equals-to' => 100
'required-entry' => true,
'validate-positive-percent-decimal' => true,
],
'visible' => $firstOption
&& $firstOption['value'] == ProductPriceOptionsInterface::VALUE_PERCENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
use Magento\Framework\View\DesignInterface;
use Magento\Store\Model\StoreManager;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\View\DesignLoader;

/**
* Collect enough information about image rendering on front
* If you want to add new image, that should render on front you need
* to configure this class in di.xml
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Image implements ProductRenderCollectorInterface
{
Expand Down Expand Up @@ -59,6 +61,11 @@ class Image implements ProductRenderCollectorInterface
*/
private $imageRenderInfoFactory;

/**
* @var DesignLoader
*/
private $designLoader;

/**
* Image constructor.
* @param ImageFactory $imageFactory
Expand All @@ -67,21 +74,25 @@ class Image implements ProductRenderCollectorInterface
* @param DesignInterface $design
* @param ImageInterfaceFactory $imageRenderInfoFactory
* @param array $imageCodes
* @param DesignLoader|null $designLoader
*/
public function __construct(
ImageFactory $imageFactory,
State $state,
StoreManagerInterface $storeManager,
DesignInterface $design,
ImageInterfaceFactory $imageRenderInfoFactory,
array $imageCodes = []
array $imageCodes = [],
DesignLoader $designLoader = null
) {
$this->imageFactory = $imageFactory;
$this->imageCodes = $imageCodes;
$this->state = $state;
$this->storeManager = $storeManager;
$this->design = $design;
$this->imageRenderInfoFactory = $imageRenderInfoFactory;
$this->designLoader = $designLoader ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(DesignLoader::class);
}

/**
Expand Down Expand Up @@ -124,6 +135,8 @@ public function collect(ProductInterface $product, ProductRenderInterface $produ
}

/**
* Callback for emulating image creation.
*
* Callback in which we emulate initialize default design theme, depends on current store, be settings store id
* from render info
*
Expand All @@ -136,7 +149,7 @@ public function collect(ProductInterface $product, ProductRenderInterface $produ
public function emulateImageCreating(ProductInterface $product, $imageCode, $storeId, ImageInterface $image)
{
$this->storeManager->setCurrentStore($storeId);
$this->design->setDefaultDesignTheme();
$this->designLoader->load();

$imageHelper = $this->imageFactory->create();
$imageHelper->init($product, $imageCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ protected function _saveProductCategories(array $categoriesData)
$delProductId[] = $productId;

foreach (array_keys($categories) as $categoryId) {
$categoriesIn[] = ['product_id' => $productId, 'category_id' => $categoryId, 'position' => 1];
$categoriesIn[] = ['product_id' => $productId, 'category_id' => $categoryId, 'position' => 0];
}
}
if (Import::BEHAVIOR_APPEND != $this->getBehavior()) {
Expand Down Expand Up @@ -1735,6 +1735,7 @@ protected function _saveProducts()
if ($uploadedFile) {
$uploadedImages[$columnImage] = $uploadedFile;
} else {
unset($rowData[$column]);
$this->addRowError(
ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE,
$rowNum,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
<element name="shippingHeading" type="button" selector="#block-shipping-heading"/>
<element name="blockSummary" type="button" selector="#block-summary"/>
<element name="discountAmount" type="text" selector="td[data-th='Discount']"/>
<element name="totalsElementByPosition" type="text" selector=".data.table.totals > tbody tr:nth-of-type({{value}}) > th" parameterized="true"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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="StorefrontCheckoutTotalsSortOrderInCartTest">
<annotations>
<title value="Checkout Totals Sort Order configuration and displaying in cart"/>
<stories value="MAGETWO-89397: Wrong Checkout Totals Sort Order in cart"/>
<description value="Checkout Totals Sort Order configuration and displaying in cart"/>
<features value="Checkout"/>
<severity value="AVERAGE"/>
<testCaseId value="MAGETWO-96635"/>
<group value="checkout"/>
</annotations>

<before>
<createData entity="_defaultCategory" stepKey="createCategory"/>
<createData entity="SimpleProduct" stepKey="createProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="SaleRule50PercentDiscountNoCoupon" stepKey="createCartRule"/>
<createData entity="CheckoutShippingTotalsSortOrder" stepKey="setConfigShippingTotalsSortOrder"/>
</before>

<after>
<deleteData createDataKey="createCartRule" stepKey="deleteCartRule"/>
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<createData entity="DefaultTotalsSortOrder" stepKey="setDefaultTotalsSortOrder"/>
</after>

<actionGroup ref="AddSimpleProductToCart" stepKey="addProductToCart">
<argument name="product" value="$$createProduct$$"/>
</actionGroup>

<actionGroup ref="VerifyDiscountAmount" stepKey="verifyDiscountAmount">
<argument name="expectedDiscount" value="-$100"/>
</actionGroup>

<see userInput="Shipping (Flat Rate - Fixed)" selector="{{StorefrontCheckoutCartSummarySection.totalsElementByPosition('3')}}" stepKey="assertElementPosition"/>
</test>
</tests>
Loading

0 comments on commit aa0c29d

Please sign in to comment.