Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit de5a2e9

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into 2.2-develop-pr66
2 parents d585a3e + f34f1f0 commit de5a2e9

File tree

14 files changed

+205
-31
lines changed

14 files changed

+205
-31
lines changed

app/code/Magento/Catalog/Test/Mftf/Test/CheckTierPricingOfProductsTest.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@
113113
<argument name="website" value="SecondWebsite"/>
114114
</actionGroup>
115115

116+
<!--Flush cache-->
117+
<magentoCLI command="cache:flush" stepKey="cleanCache"/>
118+
116119
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/>
117120
<waitForPageLoad stepKey="waitForProductsIndexPageToLoad"/>
118121
<actionGroup ref="resetAdminDataGridToDefaultView" stepKey="resetProductsGrid"/>
@@ -327,13 +330,12 @@
327330
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
328331

329332
<createData entity="DefaultConfigCatalogPrice" stepKey="resetPriceScopeConfiguration"/>
330-
331-
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteSecondWebsite">
332-
<argument name="websiteName" value="{{SecondWebsite.name}}"/>
333-
</actionGroup>
334333
<actionGroup ref="DeleteCartPriceRuleByName" stepKey="deleteCartPriceRule">
335334
<argument name="ruleName" value="ship"/>
336335
</actionGroup>
336+
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteSecondWebsite">
337+
<argument name="websiteName" value="{{SecondWebsite.name}}"/>
338+
</actionGroup>
337339
<actionGroup ref="logout" stepKey="logout"/>
338340
</after>
339341
</test>

app/code/Magento/ConfigurableProduct/Plugin/Catalog/Model/Product/Pricing/Renderer/SalableResolver.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,24 @@
55
*/
66
namespace Magento\ConfigurableProduct\Plugin\Catalog\Model\Product\Pricing\Renderer;
77

8-
use Magento\ConfigurableProduct\Pricing\Price\LowestPriceOptionsProviderInterface;
8+
use Magento\ConfigurableProduct\Model\Product\Type\Configurable as TypeConfigurable;
99

1010
/**
1111
* A plugin for a salable resolver.
1212
*/
1313
class SalableResolver
1414
{
1515
/**
16-
* @var LowestPriceOptionsProviderInterface
16+
* @var TypeConfigurable
1717
*/
18-
private $lowestPriceOptionsProvider;
18+
private $typeConfigurable;
1919

2020
/**
21-
* @param LowestPriceOptionsProviderInterface $lowestPriceOptionsProvider
21+
* @param TypeConfigurable $typeConfigurable
2222
*/
23-
public function __construct(
24-
LowestPriceOptionsProviderInterface $lowestPriceOptionsProvider
25-
) {
26-
$this->lowestPriceOptionsProvider = $lowestPriceOptionsProvider;
23+
public function __construct(TypeConfigurable $typeConfigurable)
24+
{
25+
$this->typeConfigurable = $typeConfigurable;
2726
}
2827

2928
/**
@@ -33,18 +32,16 @@ public function __construct(
3332
* @param \Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver $subject
3433
* @param bool $result
3534
* @param \Magento\Framework\Pricing\SaleableInterface $salableItem
36-
*
3735
* @return bool
38-
*
3936
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4037
*/
4138
public function afterIsSalable(
4239
\Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver $subject,
4340
$result,
4441
\Magento\Framework\Pricing\SaleableInterface $salableItem
4542
) {
46-
if ($salableItem->getTypeId() == 'configurable' && $result) {
47-
$result = $salableItem->isSalable();
43+
if ($salableItem->getTypeId() === TypeConfigurable::TYPE_CODE && $result) {
44+
$result = $this->typeConfigurable->isSalable($salableItem);
4845
}
4946

5047
return $result;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ConfigurableProduct\Test\Unit\Plugin\Catalog\Model\Product\Pricing\Renderer;
9+
10+
use Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver;
11+
use Magento\ConfigurableProduct\Model\Product\Type\Configurable as TypeConfigurable;
12+
use Magento\ConfigurableProduct\Plugin\Catalog\Model\Product\Pricing\Renderer\SalableResolver as SalableResolverPlugin;
13+
use Magento\Framework\Pricing\SaleableInterface;
14+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
15+
use PHPUnit\Framework\TestCase;
16+
17+
/**
18+
* Class SalableResolverTest
19+
*/
20+
class SalableResolverTest extends TestCase
21+
{
22+
/**
23+
* @var TypeConfigurable|MockObject
24+
*/
25+
private $typeConfigurable;
26+
27+
/**
28+
* @var SalableResolverPlugin
29+
*/
30+
private $salableResolver;
31+
32+
protected function setUp()
33+
{
34+
$this->typeConfigurable = $this->createMock(TypeConfigurable::class);
35+
$this->salableResolver = new SalableResolverPlugin($this->typeConfigurable);
36+
}
37+
38+
/**
39+
* @param SaleableInterface|MockObject $salableItem
40+
* @param bool $isSalable
41+
* @param bool $typeIsSalable
42+
* @param bool $expectedResult
43+
* @return void
44+
* @dataProvider afterIsSalableDataProvider
45+
*/
46+
public function testAfterIsSalable($salableItem, bool $isSalable, bool $typeIsSalable, bool $expectedResult)
47+
{
48+
$salableResolver = $this->createMock(SalableResolver::class);
49+
50+
$this->typeConfigurable->method('isSalable')
51+
->willReturn($typeIsSalable);
52+
53+
$result = $this->salableResolver->afterIsSalable($salableResolver, $isSalable, $salableItem);
54+
$this->assertEquals($expectedResult, $result);
55+
}
56+
57+
/**
58+
* Data provider for testAfterIsSalable
59+
*
60+
* @return array
61+
*/
62+
public function afterIsSalableDataProvider(): array
63+
{
64+
$simpleSalableItem = $this->createMock(SaleableInterface::class);
65+
$simpleSalableItem->method('getTypeId')
66+
->willReturn('simple');
67+
68+
$configurableSalableItem = $this->createMock(SaleableInterface::class);
69+
$configurableSalableItem->method('getTypeId')
70+
->willReturn('configurable');
71+
72+
return [
73+
[
74+
$simpleSalableItem,
75+
true,
76+
false,
77+
true,
78+
],
79+
[
80+
$configurableSalableItem,
81+
true,
82+
false,
83+
false,
84+
],
85+
];
86+
}
87+
}

app/code/Magento/Persistent/Model/Checkout/GuestPaymentInformationManagementPlugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ public function beforeSavePaymentInformationAndPlaceOrder(
108108
$this->customerSession->setCustomerId(null);
109109
$this->customerSession->setCustomerGroupId(null);
110110
$this->quoteManager->convertCustomerCartToGuest();
111-
/** @var \Magento\Quote\Api\Data\CartInterface $quote */
112-
$quote = $this->cartRepository->get($this->checkoutSession->getQuote()->getId());
111+
$quoteId = $this->checkoutSession->getQuoteId();
112+
$quote = $this->cartRepository->get($quoteId);
113113
$quote->setCustomerEmail($email);
114114
$quote->getAddressesCollection()->walk('setEmail', ['email' => $email]);
115115
$this->cartRepository->save($quote);

app/code/Magento/Persistent/Model/QuoteManager.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ public function setGuest($checkQuote = false)
108108
*/
109109
public function convertCustomerCartToGuest()
110110
{
111+
$quoteId = $this->checkoutSession->getQuoteId();
111112
/** @var $quote \Magento\Quote\Model\Quote */
112-
$quote = $this->quoteRepository->get($this->checkoutSession->getQuote()->getId());
113+
$quote = $this->quoteRepository->get($quoteId);
113114
if ($quote && $quote->getId()) {
114115
$this->_setQuotePersistent = false;
115116
$quote->setIsActive(true)

app/code/Magento/Persistent/Test/Unit/Model/Checkout/GuestPaymentInformationManagementPluginTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ public function testBeforeSavePaymentInformationAndPlaceOrderCartConvertsToGuest
102102
['setCustomerEmail', 'getAddressesCollection'],
103103
false
104104
);
105-
$this->checkoutSessionMock->expects($this->once())->method('getQuote')->willReturn($quoteMock);
106-
$quoteMock->expects($this->once())->method('getId')->willReturn($cartId);
105+
$this->checkoutSessionMock->method('getQuoteId')->willReturn($cartId);
107106
$this->cartRepositoryMock->expects($this->once())->method('get')->with($cartId)->willReturn($quoteMock);
108107
$quoteMock->expects($this->once())->method('setCustomerEmail')->with($email);
109108
/** @var \Magento\Framework\Data\Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */

app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ public function testConvertCustomerCartToGuest()
247247
$emailArgs = ['email' => null];
248248

249249
$this->checkoutSessionMock->expects($this->once())
250-
->method('getQuote')->willReturn($this->quoteMock);
251-
$this->quoteMock->expects($this->exactly(2))->method('getId')->willReturn($quoteId);
250+
->method('getQuoteId')->willReturn($quoteId);
251+
$this->quoteMock->expects($this->once())->method('getId')->willReturn($quoteId);
252252
$this->quoteRepositoryMock->expects($this->once())->method('get')->with($quoteId)->willReturn($this->quoteMock);
253253
$this->quoteMock->expects($this->once())
254254
->method('setIsActive')->with(true)->willReturn($this->quoteMock);
@@ -288,18 +288,15 @@ public function testConvertCustomerCartToGuest()
288288
public function testConvertCustomerCartToGuestWithEmptyQuote()
289289
{
290290
$this->checkoutSessionMock->expects($this->once())
291-
->method('getQuote')->willReturn($this->quoteMock);
292-
$this->quoteMock->expects($this->once())->method('getId')->willReturn(null);
291+
->method('getQuoteId')->willReturn(null);
293292
$this->quoteRepositoryMock->expects($this->once())->method('get')->with(null)->willReturn(null);
294-
295293
$this->model->convertCustomerCartToGuest();
296294
}
297295

298296
public function testConvertCustomerCartToGuestWithEmptyQuoteId()
299297
{
300298
$this->checkoutSessionMock->expects($this->once())
301-
->method('getQuote')->willReturn($this->quoteMock);
302-
$this->quoteMock->expects($this->once())->method('getId')->willReturn(1);
299+
->method('getQuoteId')->willReturn(1);
303300
$quoteWithNoId = $this->quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
304301
$quoteWithNoId->expects($this->once())->method('getId')->willReturn(null);
305302
$this->quoteRepositoryMock->expects($this->once())->method('get')->with(1)->willReturn($quoteWithNoId);

app/code/Magento/Sales/etc/di.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,10 @@
746746
<virtualType name="ShippingAddressAggregator" type="Magento\Framework\DB\Sql\ConcatExpression">
747747
<arguments>
748748
<argument name="columns" xsi:type="array">
749+
<item name="company" xsi:type="array">
750+
<item name="tableAlias" xsi:type="string">sales_shipping_address</item>
751+
<item name="columnName" xsi:type="string">company</item>
752+
</item>
749753
<item name="street" xsi:type="array">
750754
<item name="tableAlias" xsi:type="string">sales_shipping_address</item>
751755
<item name="columnName" xsi:type="string">street</item>
@@ -769,6 +773,10 @@
769773
<virtualType name="BillingAddressAggregator" type="Magento\Framework\DB\Sql\ConcatExpression">
770774
<arguments>
771775
<argument name="columns" xsi:type="array">
776+
<item name="company" xsi:type="array">
777+
<item name="tableAlias" xsi:type="string">sales_billing_address</item>
778+
<item name="columnName" xsi:type="string">company</item>
779+
</item>
772780
<item name="street" xsi:type="array">
773781
<item name="tableAlias" xsi:type="string">sales_billing_address</item>
774782
<item name="columnName" xsi:type="string">street</item>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="ChangeCartPriceRuleWebsiteActionGroup">
11+
<arguments>
12+
<argument name="websiteLabel" type="string"/>
13+
</arguments>
14+
<waitForPageLoad stepKey="waitForPriceList"/>
15+
<selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="{{websiteLabel}}" stepKey="selectWebsites"/>
16+
<click selector="{{AdminCartPriceRulesFormSection.save}}" stepKey="clickSaveButton"/>
17+
</actionGroup>
18+
</actionGroups>

app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/dataProfileSchema.xsd">
1111
<entity name="ApiSalesRule" type="SalesRule">
1212
<data key="name" unique="suffix">salesRule</data>
1313
<data key="description">Sales Rule Descritpion</data>
@@ -113,4 +113,32 @@
113113
<data key="uses_per_coupon">0</data>
114114
<data key="simple_free_shipping">0</data>
115115
</entity>
116+
<entity name="ApiCartRule" type="SalesRule">
117+
<data key="name" unique="suffix">salesRule</data>
118+
<data key="description">Sales Rule Descritpion</data>
119+
<array key="website_ids">
120+
<item>1</item>
121+
</array>
122+
<array key="customer_group_ids">
123+
<item>0</item>
124+
<item>1</item>
125+
<item>3</item>
126+
</array>
127+
<data key="uses_per_customer">0</data>
128+
<data key="is_active">true</data>
129+
<data key="stop_rules_processing">true</data>
130+
<data key="is_advanced">true</data>
131+
<data key="sort_order">0</data>
132+
<data key="simple_action">by_percent</data>
133+
<data key="discount_amount">50</data>
134+
<data key="discount_qty">0</data>
135+
<data key="discount_step">0</data>
136+
<data key="apply_to_shipping">false</data>
137+
<data key="times_used">0</data>
138+
<data key="is_rss">true</data>
139+
<data key="coupon_type">NO_COUPON</data>
140+
<data key="use_auto_generation">false</data>
141+
<data key="uses_per_coupon">0</data>
142+
<data key="simple_free_shipping">0</data>
143+
</entity>
116144
</entities>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/PageObject.xsd">
10+
<page name="AdminCartPriceRuleEditPage" url="sales_rule/promo_quote/edit/id/{{ruleId}}/" area="admin" module="Magento_SalesRule" parameterized="true"/>
11+
</pages>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/PageObject.xsd">
9+
<page name="AdminCartPriceRulesLimitPage" url="sales_rule/promo_quote/index/limit/{{count}}" area="admin" module="Magento_SalesRule" parameterized="true"/>
10+
</pages>

app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesSection.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/SectionObject.xsd">
1010
<section name="AdminCartPriceRulesSection">
1111
<element name="addNewRuleButton" type="button" selector="#add" timeout="30"/>
1212
<element name="messages" type="text" selector=".messages"/>
@@ -15,5 +15,9 @@
1515
<element name="rowByIndex" type="text" selector="tr[data-role='row']:nth-of-type({{var1}})" parameterized="true" timeout="30"/>
1616
<element name="nameColumns" type="text" selector="td[data-column='name']"/>
1717
<element name="rowContainingText" type="text" selector="//*[@id='promo_quote_grid_table']/tbody/tr[td//text()[contains(., '{{var1}}')]]" parameterized="true" timeout="30"/>
18+
<element name="rulesRow" type="text" selector="//tr[@data-role='row']"/>
19+
<element name="pageCurrent" type="text" selector="//label[@for='promo_quote_grid_page-current']"/>
20+
<element name="countPages" type="text" selector="//label[@for='promo_quote_grid_page-current']//span"/>
21+
<element name="totalCount" type="text" selector="span[data-ui-id*='grid-total-count']"/>
1822
</section>
1923
</sections>

app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/dataProfileSchema.xsd">
1111
<entity name="adminProductInWebsiteRole" type="user_role">
1212
<data key="rolename" unique="suffix">restrictedWebsiteRole</data>
1313
<data key="current_password">123123q</data>
@@ -34,4 +34,16 @@
3434
<data key="rolename" unique="suffix">RoleTest</data>
3535
<data key="current_password">123123q</data>
3636
</entity>
37+
<entity name="adminMarketingInWebsiteRole" type="user_role">
38+
<data key="rolename" unique="suffix">restrictedWebsiteRole</data>
39+
<data key="current_password">123123q</data>
40+
<data key="gws_is_all">0</data>
41+
<array key="gws_websites">
42+
<item>1</item>
43+
</array>
44+
<array key="resource">
45+
<item>Magento_Backend::marketing</item>
46+
<item>Magento_SalesRule::quote</item>
47+
</array>
48+
</entity>
3749
</entities>

0 commit comments

Comments
 (0)