Skip to content

Commit

Permalink
Merge branch 2.3-develop into ENGCOM-4389-magento-magento2-21458
Browse files Browse the repository at this point in the history
  • Loading branch information
magento-engcom-team committed Feb 28, 2019
2 parents 5c01357 + a5330a7 commit 5d12e16
Show file tree
Hide file tree
Showing 35 changed files with 775 additions and 67 deletions.
4 changes: 3 additions & 1 deletion app/code/Magento/Backend/Model/Session/Quote.php
Expand Up @@ -24,6 +24,7 @@
* @method Quote setOrderId($orderId)
* @method int getOrderId()
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
* @since 100.0.2
*/
class Quote extends \Magento\Framework\Session\SessionManager
Expand Down Expand Up @@ -149,7 +150,8 @@ public function getQuote()
$this->_quote = $this->quoteFactory->create();
if ($this->getStoreId()) {
if (!$this->getQuoteId()) {
$this->_quote->setCustomerGroupId($this->groupManagement->getDefaultGroup()->getId());
$customerGroupId = $this->groupManagement->getDefaultGroup($this->getStoreId())->getId();
$this->_quote->setCustomerGroupId($customerGroupId);
$this->_quote->setIsActive(false);
$this->_quote->setStoreId($this->getStoreId());

Expand Down
Expand Up @@ -267,7 +267,10 @@ public function testGetQuoteWithoutQuoteId()
$cartInterfaceMock->expects($this->atLeastOnce())->method('getId')->willReturn($quoteId);
$defaultGroup = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class)->getMock();
$defaultGroup->expects($this->any())->method('getId')->will($this->returnValue($customerGroupId));
$this->groupManagementMock->expects($this->any())->method('getDefaultGroup')->willReturn($defaultGroup);
$this->groupManagementMock
->method('getDefaultGroup')
->with($storeId)
->willReturn($defaultGroup);

$dataCustomerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
->disableOriginalConstructor()
Expand Down
Expand Up @@ -263,4 +263,15 @@
<click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategory"/>
<seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="assertSuccessMessage"/>
</actionGroup>

<actionGroup name="AdminAssignProductToCategory">
<arguments>
<argument name="productId" type="string"/>
<argument name="categoryName" type="string"/>
</arguments>
<amOnPage url="{{AdminProductEditPage.url(productId)}}" stepKey="amOnPage"/>
<searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="[{{categoryName}}]" stepKey="selectCategory"/>
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickOnSaveButton"/>
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the product." stepKey="seeSaveProductMessage"/>
</actionGroup>
</actionGroups>
19 changes: 19 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/ProductLinkData.xml
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="RelatedProductLink" type="product_link">
<var key="sku" entityKey="sku" entityType="product2"/>
<var key="linked_product_sku" entityKey="sku" entityType="product"/>
<data key="link_type">related</data>
<data key="linked_product_type">simple</data>
<data key="position">1</data>
<requiredEntity type="product_link_extension_attribute">Qty1000</requiredEntity>
</entity>
</entities>
14 changes: 14 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/ProductLinksData.xml
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="OneRelatedProductLink" type="product_links">
<requiredEntity type="product_link">RelatedProductLink</requiredEntity>
</entity>
</entities>
15 changes: 15 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/WidgetsData.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="ProductLinkWidget" extends="ProductsListWidget">
<data key="type">Catalog Product Link</data>
<data key="template">Product Link Block Template</data>
</entity>
</entities>
14 changes: 14 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Page/AdminNewWidgetPage.xml
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
<page name="AdminNewWidgetPage" url="admin/widget_instance/new/" area="admin" module="Magento_Widget">
<section name="AdminNewWidgetSelectProductPopupSection"/>
</page>
</pages>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminNewWidgetSection">
<element name="selectProduct" type="button" selector=".btn-chooser" timeout="30"/>
</section>
</sections>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminNewWidgetSelectProductPopupSection">
<element name="filterBySku" type="input" selector=".data-grid-filters input[name='chooser_sku']"/>
<element name="firstRow" type="select" selector=".even>td" timeout="20"/>
</section>
</sections>
@@ -0,0 +1,32 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CatalogInventory\Ui\DataProvider\Product;

use Magento\Framework\Data\Collection;
use Magento\Ui\DataProvider\AddFieldToCollectionInterface;

/**
* Add quantity_and_stock_status field to collection
*/
class AddQuantityAndStockStatusFieldToCollection implements AddFieldToCollectionInterface
{
/**
* @inheritdoc
*/
public function addField(Collection $collection, $field, $alias = null)
{
$collection->joinField(
'quantity_and_stock_status',
'cataloginventory_stock_item',
'is_in_stock',
'product_id=entity_id',
'{{table}}.stock_id=1',
'left'
);
}
}
1 change: 1 addition & 0 deletions app/code/Magento/CatalogInventory/etc/adminhtml/di.xml
Expand Up @@ -23,6 +23,7 @@
<arguments>
<argument name="addFieldStrategies" xsi:type="array">
<item name="qty" xsi:type="object">Magento\CatalogInventory\Ui\DataProvider\Product\AddQuantityFieldToCollection</item>
<item name="quantity_and_stock_status" xsi:type="object">Magento\CatalogInventory\Ui\DataProvider\Product\AddQuantityAndStockStatusFieldToCollection</item>
</argument>
<argument name="addFilterStrategies" xsi:type="array">
<item name="qty" xsi:type="object">Magento\CatalogInventory\Ui\DataProvider\Product\AddQuantityFilterToCollection</item>
Expand Down
Expand Up @@ -13,3 +13,10 @@
$block->escapeUrl($block->getContinueShoppingUrl())) ?></p>
<?= $block->getChildHtml('shopping.cart.table.after') ?>
</div>
<script type="text/x-magento-init">
{
"*": {
"Magento_Checkout/js/empty-cart": {}
}
}
</script>
16 changes: 16 additions & 0 deletions app/code/Magento/Checkout/view/frontend/web/js/empty-cart.js
@@ -0,0 +1,16 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

define([
'Magento_Customer/js/customer-data'
], function (customerData) {
'use strict';

var cartData = customerData.get('cart');

if (cartData().items && cartData().items.length !== 0) {
customerData.reload(['cart'], false);
}
});
@@ -0,0 +1,44 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\ConfigurableProduct\Plugin\Tax\Model\Sales\Total\Quote;

use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
use Magento\Quote\Model\Quote\Item\AbstractItem;
use Magento\Tax\Api\Data\QuoteDetailsItemInterface;
use Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory;

/**
* Plugin for CommonTaxCollector to apply Tax Class ID from child item for configurable product
*/
class CommonTaxCollector
{
/**
* Apply Tax Class ID from child item for configurable product
*
* @param \Magento\Tax\Model\Sales\Total\Quote\CommonTaxCollector $subject
* @param QuoteDetailsItemInterface $result
* @param QuoteDetailsItemInterfaceFactory $itemDataObjectFactory
* @param AbstractItem $item
* @return QuoteDetailsItemInterface
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterMapItem(
\Magento\Tax\Model\Sales\Total\Quote\CommonTaxCollector $subject,
QuoteDetailsItemInterface $result,
QuoteDetailsItemInterfaceFactory $itemDataObjectFactory,
AbstractItem $item
) : QuoteDetailsItemInterface {
if ($item->getProduct()->getTypeId() === Configurable::TYPE_CODE && $item->getHasChildren()) {
$childItem = $item->getChildren()[0];
$result->getTaxClassKey()->setValue($childItem->getProduct()->getTaxClassId());
}

return $result;
}
}
Expand Up @@ -62,4 +62,17 @@
<requiredEntity createDataKey="createConfigChildProduct2"/>
</createData>
</actionGroup>

<!-- Create the configurable product, children are not visible individually -->
<actionGroup name="AdminCreateApiConfigurableProductWithHiddenChildActionGroup" extends="AdminCreateApiConfigurableProductActionGroup">
<!-- Create the 2 children that will be a part of the configurable product -->
<createData entity="ApiSimpleOneHidden" stepKey="createConfigChildProduct1">
<requiredEntity createDataKey="createConfigProductAttribute"/>
<requiredEntity createDataKey="getConfigAttributeOption1"/>
</createData>
<createData entity="ApiSimpleTwoHidden" stepKey="createConfigChildProduct2">
<requiredEntity createDataKey="createConfigProductAttribute"/>
<requiredEntity createDataKey="getConfigAttributeOption2"/>
</createData>
</actionGroup>
</actionGroups>
@@ -0,0 +1,94 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\ConfigurableProduct\Test\Unit\Plugin\Tax\Model\Sales\Total\Quote;

use Magento\Catalog\Model\Product;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
use Magento\ConfigurableProduct\Plugin\Tax\Model\Sales\Total\Quote\CommonTaxCollector as CommonTaxCollectorPlugin;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Quote\Model\Quote\Item\AbstractItem;
use Magento\Tax\Api\Data\QuoteDetailsItemInterface;
use Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory;
use Magento\Tax\Api\Data\TaxClassKeyInterface;
use Magento\Tax\Model\Sales\Total\Quote\CommonTaxCollector;
use PHPUnit\Framework\MockObject\MockObject;

/**
* Test for CommonTaxCollector plugin
*/
class CommonTaxCollectorTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
*/
private $objectManager;

/**
* @var CommonTaxCollectorPlugin
*/
private $commonTaxCollectorPlugin;

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

/**
* Test to apply Tax Class Id from child item for configurable product
*/
public function testAfterMapItem()
{
$childTaxClassId = 10;

/** @var Product|MockObject $childProductMock */
$childProductMock = $this->createPartialMock(
Product::class,
['getTaxClassId']
);
$childProductMock->method('getTaxClassId')->willReturn($childTaxClassId);
/* @var AbstractItem|MockObject $quoteItemMock */
$childQuoteItemMock = $this->createMock(
AbstractItem::class
);
$childQuoteItemMock->method('getProduct')->willReturn($childProductMock);

/** @var Product|MockObject $productMock */
$productMock = $this->createPartialMock(
Product::class,
['getTypeId']
);
$productMock->method('getTypeId')->willReturn(Configurable::TYPE_CODE);
/* @var AbstractItem|MockObject $quoteItemMock */
$quoteItemMock = $this->createPartialMock(
AbstractItem::class,
['getProduct', 'getHasChildren', 'getChildren', 'getQuote', 'getAddress', 'getOptionByCode']
);
$quoteItemMock->method('getProduct')->willReturn($productMock);
$quoteItemMock->method('getHasChildren')->willReturn(true);
$quoteItemMock->method('getChildren')->willReturn([$childQuoteItemMock]);

/* @var TaxClassKeyInterface|MockObject $taxClassObjectMock */
$taxClassObjectMock = $this->createMock(TaxClassKeyInterface::class);
$taxClassObjectMock->expects($this->once())->method('setValue')->with($childTaxClassId);

/* @var QuoteDetailsItemInterface|MockObject $quoteDetailsItemMock */
$quoteDetailsItemMock = $this->createMock(QuoteDetailsItemInterface::class);
$quoteDetailsItemMock->method('getTaxClassKey')->willReturn($taxClassObjectMock);

$this->commonTaxCollectorPlugin->afterMapItem(
$this->createMock(CommonTaxCollector::class),
$quoteDetailsItemMock,
$this->createMock(QuoteDetailsItemInterfaceFactory::class),
$quoteItemMock
);
}
}
3 changes: 2 additions & 1 deletion app/code/Magento/ConfigurableProduct/composer.json
Expand Up @@ -25,7 +25,8 @@
"magento/module-sales-rule": "*",
"magento/module-product-video": "*",
"magento/module-configurable-sample-data": "*",
"magento/module-product-links-sample-data": "*"
"magento/module-product-links-sample-data": "*",
"magento/module-tax": "*"
},
"type": "magento2-module",
"license": [
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/ConfigurableProduct/etc/di.xml
Expand Up @@ -245,4 +245,7 @@
<type name="Magento\SalesRule\Model\Rule\Condition\Product">
<plugin name="apply_rule_on_configurable_children" type="Magento\ConfigurableProduct\Plugin\SalesRule\Model\Rule\Condition\Product" />
</type>
<type name="Magento\Tax\Model\Sales\Total\Quote\CommonTaxCollector">
<plugin name="apply_tax_class_id" type="Magento\ConfigurableProduct\Plugin\Tax\Model\Sales\Total\Quote\CommonTaxCollector" />
</type>
</config>

0 comments on commit 5d12e16

Please sign in to comment.