Skip to content

Commit 7312e56

Browse files
authored
Merge pull request magento#4929 from magento-mpi/MPI-PR-2019-10-25
MPI-PR-2019-10-25
2 parents 496a855 + 1f68a3c commit 7312e56

File tree

12 files changed

+298
-29
lines changed

12 files changed

+298
-29
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,10 +2520,10 @@ public function getPricesCount()
25202520
/**
25212521
* Add is_saleable attribute to filter
25222522
*
2523-
* @param array|null $condition
2523+
* @param mixed $condition
25242524
* @return $this
25252525
*/
2526-
private function addIsSaleableAttributeToFilter(?array $condition): self
2526+
private function addIsSaleableAttributeToFilter($condition): self
25272527
{
25282528
$columns = $this->getSelect()->getPart(Select::COLUMNS);
25292529
foreach ($columns as $columnEntry) {
@@ -2551,10 +2551,10 @@ private function addIsSaleableAttributeToFilter(?array $condition): self
25512551
* Add tier price attribute to filter
25522552
*
25532553
* @param string $attribute
2554-
* @param array|null $condition
2554+
* @param mixed $condition
25552555
* @return $this
25562556
*/
2557-
private function addTierPriceAttributeToFilter(string $attribute, ?array $condition): self
2557+
private function addTierPriceAttributeToFilter(string $attribute, $condition): self
25582558
{
25592559
$attrCode = $attribute;
25602560
$connection = $this->getConnection();

app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
<!-- Run cron twice -->
230230
<magentoCLI command="cron:run" stepKey="runCron1"/>
231231
<magentoCLI command="cron:run" stepKey="runCron2"/>
232+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
232233

233234
<!-- Go to Frontend and open the simple product -->
234235
<amOnPage url="{{StorefrontProductPage.url($$createFirstProduct.sku$$)}}" stepKey="amOnSimpleProductPage"/>

app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\CatalogUrlRewrite\Model\Product;
77

88
use Magento\Catalog\Api\CategoryRepositoryInterface;
9+
use Magento\Catalog\Model\Category;
910
use Magento\Catalog\Model\Product;
1011
use Magento\CatalogUrlRewrite\Model\ObjectRegistry;
1112
use Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator;
@@ -67,6 +68,9 @@ public function generate($storeId, Product $product, ObjectRegistry $productCate
6768
if ($anchorCategoryIds) {
6869
foreach ($anchorCategoryIds as $anchorCategoryId) {
6970
$anchorCategory = $this->categoryRepository->get($anchorCategoryId);
71+
if ((int)$anchorCategory->getParentId() === Category::TREE_ROOT_ID) {
72+
continue;
73+
}
7074
$urls[] = $this->urlRewriteFactory->create()
7175
->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE)
7276
->setEntityId($product->getId())
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\CatalogUrlRewrite\Test\Unit\Model\Product;
7+
8+
use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator;
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
10+
11+
class AnchorUrlRewriteGeneratorTest extends \PHPUnit\Framework\TestCase
12+
{
13+
/** @var \Magento\CatalogUrlRewrite\Model\Product\AnchorUrlRewriteGenerator */
14+
protected $anchorUrlRewriteGenerator;
15+
16+
/** @var \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator|\PHPUnit_Framework_MockObject_MockObject */
17+
protected $productUrlPathGenerator;
18+
19+
/** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */
20+
protected $product;
21+
22+
/** @var \Magento\Catalog\Api\CategoryRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject */
23+
private $categoryRepositoryInterface;
24+
25+
/** @var \Magento\CatalogUrlRewrite\Model\ObjectRegistry|\PHPUnit_Framework_MockObject_MockObject */
26+
protected $categoryRegistry;
27+
28+
/** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory|\PHPUnit_Framework_MockObject_MockObject */
29+
protected $urlRewriteFactory;
30+
31+
/** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewrite|\PHPUnit_Framework_MockObject_MockObject */
32+
protected $urlRewrite;
33+
34+
protected function setUp()
35+
{
36+
$this->urlRewriteFactory = $this->getMockBuilder(\Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory::class)
37+
->setMethods(['create'])
38+
->disableOriginalConstructor()->getMock();
39+
$this->urlRewrite = $this->getMockBuilder(\Magento\UrlRewrite\Service\V1\Data\UrlRewrite::class)
40+
->disableOriginalConstructor()->getMock();
41+
$this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
42+
->disableOriginalConstructor()->getMock();
43+
$this->categoryRepositoryInterface = $this->getMockBuilder(
44+
\Magento\Catalog\Api\CategoryRepositoryInterface::class
45+
)->disableOriginalConstructor()->getMock();
46+
$this->categoryRegistry = $this->getMockBuilder(\Magento\CatalogUrlRewrite\Model\ObjectRegistry::class)
47+
->disableOriginalConstructor()->getMock();
48+
$this->productUrlPathGenerator = $this->getMockBuilder(
49+
\Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator::class
50+
)->disableOriginalConstructor()->getMock();
51+
$this->anchorUrlRewriteGenerator = (new ObjectManager($this))->getObject(
52+
\Magento\CatalogUrlRewrite\Model\Product\AnchorUrlRewriteGenerator::class,
53+
[
54+
'productUrlPathGenerator' => $this->productUrlPathGenerator,
55+
'urlRewriteFactory' => $this->urlRewriteFactory,
56+
'categoryRepository' => $this->categoryRepositoryInterface
57+
]
58+
);
59+
}
60+
61+
public function testGenerateEmpty()
62+
{
63+
$this->categoryRegistry->expects($this->any())->method('getList')->will($this->returnValue([]));
64+
65+
$this->assertEquals(
66+
[],
67+
$this->anchorUrlRewriteGenerator->generate(1, $this->product, $this->categoryRegistry)
68+
);
69+
}
70+
71+
public function testGenerateCategories()
72+
{
73+
$urlPathWithCategory = 'category1/category2/category3/simple-product.html';
74+
$storeId = 10;
75+
$productId = 12;
76+
$canonicalUrlPathWithCategory = 'canonical-path-with-category';
77+
$categoryParentId = '1';
78+
$categoryIds = [$categoryParentId,'2','3','4'];
79+
$urls = ['category1/simple-product.html',
80+
'category1/category2/simple-product.html',
81+
'category1/category2/category3/simple-product.html'];
82+
83+
$this->product->expects($this->any())->method('getId')->will($this->returnValue($productId));
84+
$this->productUrlPathGenerator->expects($this->any())->method('getUrlPathWithSuffix')
85+
->will($this->returnValue($urlPathWithCategory));
86+
$this->productUrlPathGenerator->expects($this->any())->method('getCanonicalUrlPath')
87+
->will($this->returnValue($canonicalUrlPathWithCategory));
88+
$category = $this->createMock(\Magento\Catalog\Model\Category::class);
89+
$category->expects($this->any())->method('getId')->will($this->returnValue($categoryIds));
90+
$category->expects($this->any())->method('getAnchorsAbove')->will($this->returnValue($categoryIds));
91+
$category->expects($this->any())->method('getParentId')->will(
92+
$this->onConsecutiveCalls(
93+
$categoryIds[0],
94+
$categoryIds[1],
95+
$categoryIds[2],
96+
$categoryIds[3]
97+
)
98+
);
99+
$this->categoryRepositoryInterface
100+
->expects($this->any())
101+
->method('get')
102+
->withConsecutive(
103+
[ 'category_id' => $categoryIds[0]],
104+
[ 'category_id' => $categoryIds[1]],
105+
[ 'category_id' => $categoryIds[2]]
106+
)
107+
->will($this->returnValue($category));
108+
$this->categoryRegistry->expects($this->any())->method('getList')
109+
->will($this->returnValue([$category]));
110+
$this->urlRewrite->expects($this->any())->method('setStoreId')
111+
->with($storeId)
112+
->will($this->returnSelf());
113+
$this->urlRewrite->expects($this->any())->method('setEntityId')
114+
->with($productId)
115+
->will($this->returnSelf());
116+
$this->urlRewrite->expects($this->any())->method('setEntityType')
117+
->with(ProductUrlRewriteGenerator::ENTITY_TYPE)
118+
->will($this->returnSelf());
119+
$this->urlRewrite->expects($this->any())->method('setRequestPath')
120+
->will($this->returnSelf());
121+
$this->urlRewrite->expects($this->any())->method('setTargetPath')
122+
->will($this->returnSelf());
123+
$this->urlRewrite->expects($this->any())->method('setMetadata')
124+
->will(
125+
$this->onConsecutiveCalls(
126+
$urls[0],
127+
$urls[1],
128+
$urls[2]
129+
)
130+
);
131+
$this->urlRewriteFactory->expects($this->any())->method('create')->will(
132+
$this->returnValue($this->urlRewrite)
133+
);
134+
135+
$this->assertEquals(
136+
$urls,
137+
$this->anchorUrlRewriteGenerator->generate($storeId, $this->product, $this->categoryRegistry)
138+
);
139+
}
140+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontCustomerCheckoutDisabledProductAndCouponTest">
11+
<annotations>
12+
<features value="Checkout"/>
13+
<stories value="Checkout via the Storefront"/>
14+
<title value="Customer can login if product in his cart was disabled"/>
15+
<description value="Customer can login with disabled product in the cart and a coupon applied"/>
16+
<severity value="MINOR"/>
17+
<testCaseId value="MC-21996"/>
18+
<group value="checkout"/>
19+
</annotations>
20+
21+
<before>
22+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
23+
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
24+
<requiredEntity createDataKey="createCategory"/>
25+
</createData>
26+
<createData entity="Simple_US_Customer" stepKey="createUSCustomer"/>
27+
<!-- Create sales rule with coupon -->
28+
<createData entity="SalesRuleSpecificCouponAndByPercent" stepKey="createSalesRule"/>
29+
<createData entity="SimpleSalesRuleCoupon" stepKey="createCouponForCartPriceRule">
30+
<requiredEntity createDataKey="createSalesRule"/>
31+
</createData>
32+
</before>
33+
<after>
34+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
35+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
36+
<deleteData createDataKey="createUSCustomer" stepKey="deleteCustomer"/>
37+
<deleteData createDataKey="createSalesRule" stepKey="deleteSalesRule"/>
38+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductListing"/>
39+
<actionGroup ref="resetProductGridToDefaultView" stepKey="resetGridToDefaultKeywordSearch"/>
40+
</after>
41+
42+
<!-- Login as Customer -->
43+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="customerLogin">
44+
<argument name="Customer" value="$$createUSCustomer$$" />
45+
</actionGroup>
46+
47+
<!-- Add product to shopping cart -->
48+
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.name$$)}}" stepKey="amOnSimpleProductPage"/>
49+
<actionGroup ref="AddSimpleProductToCart" stepKey="cartAddSimpleProductToCart">
50+
<argument name="product" value="$$createSimpleProduct$$"/>
51+
<argument name="productCount" value="1"/>
52+
</actionGroup>
53+
54+
<!-- Open View and edit -->
55+
<actionGroup ref="clickViewAndEditCartFromMiniCart" stepKey="clickMiniCart1"/>
56+
57+
<!-- Fill the Estimate Shipping and Tax section -->
58+
<actionGroup ref="CheckoutFillEstimateShippingAndTaxActionGroup" stepKey="fillEstimateShippingAndTaxFields"/>
59+
60+
<!-- Apply Coupon -->
61+
<actionGroup ref="StorefrontApplyCouponActionGroup" stepKey="applyDiscount">
62+
<argument name="coupon" value="$$createCouponForCartPriceRule$$"/>
63+
</actionGroup>
64+
65+
<!-- Sign out Customer from storefront -->
66+
<actionGroup ref="StorefrontSignOutActionGroup" stepKey="customerLogout"/>
67+
68+
<!-- Login to admin panel -->
69+
<openNewTab stepKey="openNewTab"/>
70+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
71+
72+
<!-- Find the first simple product that we just created using the product grid and go to its page-->
73+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPage"/>
74+
75+
<!-- Disabled simple product from grid -->
76+
<actionGroup ref="ChangeStatusProductUsingProductGridActionGroup" stepKey="disabledProductFromGrid">
77+
<argument name="product" value="$$createSimpleProduct$$"/>
78+
<argument name="status" value="Disable"/>
79+
</actionGroup>
80+
<closeTab stepKey="closeTab"/>
81+
82+
<!-- Login as Customer -->
83+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="customerLoginSecondTime">
84+
<argument name="Customer" value="$$createUSCustomer$$" />
85+
</actionGroup>
86+
87+
<!-- Check cart -->
88+
<click selector="{{StorefrontMiniCartSection.show}}" stepKey="clickMiniCart2"/>
89+
<dontSeeElement selector="{{StorefrontMiniCartSection.quantity}}" stepKey="dontSeeCartItem"/>
90+
</test>
91+
</tests>

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@
113113
</createData>
114114
<magentoCLI stepKey="allowSpecificValue" command="config:set payment/checkmo/allowspecific 1" />
115115
<magentoCLI stepKey="specificCountryValue" command="config:set payment/checkmo/specificcountry GB" />
116-
116+
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
117+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
117118
</before>
118119
<after>
119120
<actionGroup ref="logout" stepKey="adminLogout"/>

app/code/Magento/Paypal/Model/SmartButtonConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function getConfig(string $page): array
8383
'allowedFunding' => $this->getAllowedFunding($page),
8484
'disallowedFunding' => $this->getDisallowedFunding(),
8585
'styles' => $this->getButtonStyles($page),
86-
'isVisibleOnProductPage' => $this->config->getValue('visible_on_product'),
86+
'isVisibleOnProductPage' => (bool)$this->config->getValue('visible_on_product'),
8787
'isGuestCheckoutAllowed' => $isGuestCheckoutAllowed
8888
];
8989
}

app/code/Magento/Paypal/Test/Unit/Model/_files/expected_config.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
'label' => 'installment',
3333
'installmentperiod' => 0
3434
],
35-
'isVisibleOnProductPage' => 0,
35+
'isVisibleOnProductPage' => false,
3636
'isGuestCheckoutAllowed' => true
3737
]
3838
],
@@ -62,7 +62,7 @@
6262
'label' => 'installment',
6363
'installmentperiod' => 0
6464
],
65-
'isVisibleOnProductPage' => 0,
65+
'isVisibleOnProductPage' => false,
6666
'isGuestCheckoutAllowed' => true
6767
]
6868
],
@@ -91,7 +91,7 @@
9191
'shape' => 'rect',
9292
'label' => 'paypal'
9393
],
94-
'isVisibleOnProductPage' => 0,
94+
'isVisibleOnProductPage' => false,
9595
'isGuestCheckoutAllowed' => true
9696
]
9797
],
@@ -120,7 +120,7 @@
120120
'shape' => 'rect',
121121
'label' => 'paypal'
122122
],
123-
'isVisibleOnProductPage' => 0,
123+
'isVisibleOnProductPage' => false,
124124
'isGuestCheckoutAllowed' => true
125125
]
126126
],
@@ -149,7 +149,7 @@
149149
'shape' => 'rect',
150150
'label' => 'paypal',
151151
],
152-
'isVisibleOnProductPage' => 0,
152+
'isVisibleOnProductPage' => false,
153153
'isGuestCheckoutAllowed' => true
154154
]
155155
]

app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ protected function _assignProducts(): self
276276
}
277277
}
278278
if ($this->recollectQuote && $this->_quote) {
279-
$this->_quote->collectTotals();
279+
$this->_quote->setTotalsCollectedFlag(false);
280280
}
281281
\Magento\Framework\Profiler::stop('QUOTE:' . __METHOD__);
282282

app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddProductsToCartFromWishlistUsingSidebarTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
<createData entity="SimpleProduct" stepKey="simpleProduct2">
2626
<requiredEntity createDataKey="categorySecond"/>
2727
</createData>
28+
<createData entity="Simple_US_Customer" stepKey="customer"/>
2829
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
2930
<magentoCLI command="cache:flush" stepKey="flushCache"/>
30-
<createData entity="Simple_US_Customer" stepKey="customer"/>
3131
</before>
3232
<after>
3333
<deleteData createDataKey="simpleProduct1" stepKey="deleteSimpleProduct1"/>

0 commit comments

Comments
 (0)