Skip to content

Commit d1fbf76

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.3-develop
Accepted Community Pull Requests: - magento#24538: [Tax] Confirmation popup improvement (by @eduard13) - magento#24516: [SalesRule] Covering the CouponCodeValidation class by Unit Tests (by @eduard13) - magento#24411: change shopping cart to minicart (by @sunilit42) - magento#24392: MAGETWO-24349: Added br as allowed tag (by @wwwadminwww) - magento#24320: fixed File type custom option value not showing properly on wish list page magento#24319 (by @rani-webkul) - magento#22886: Fix random fails during parallel SCD execution (by @ihor-sviziev) - magento#24497: Fixed issue:24031 Layer navigation displaying whenever select Static … (by @maheshWebkul721) Fixed GitHub Issues: - magento#24537: Remove tax rule popup not same as per other default popup (reported by @bhavik43) has been fixed in magento#24538 by @eduard13 in 2.3-develop branch Related commits: 1. 635c38f 2. 054d959 - magento#24409: Shopping Cart Sidebar should be Minicart (reported by @sunilit42) has been fixed in magento#24411 by @sunilit42 in 2.3-develop branch Related commits: 1. 95cad1a 2. 29a1544 3. bc1657b 4. 6b3c12e - magento#24349: contradictory when using escapeHtml after getFormattedOption (reported by @dbsdsun) has been fixed in magento#24392 by @wwwadminwww in 2.3-develop branch Related commits: 1. f02e791 - magento#24319: File type custom option value not showing properly on wish list page (reported by @rani-webkul) has been fixed in magento#24320 by @rani-webkul in 2.3-develop branch Related commits: 1. 62c216c - magento#22880: Static content deploy - Randomly css files not generated (reported by @ihor-sviziev) has been fixed in magento#22886 by @ihor-sviziev in 2.3-develop branch Related commits: 1. 63063bc 2. 0f43b32 - magento#24031: Layer navigation displaying whenever select Static Block onl (reported by @ankitpatel2931) has been fixed in magento#24497 by @maheshWebkul721 in 2.3-develop branch Related commits: 1. a579c20 2. 2ed72ca
2 parents 70d2287 + 5d4906b commit d1fbf76

File tree

14 files changed

+296
-99
lines changed

14 files changed

+296
-99
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
<argument name="total" value="110.00"/>
110110
</actionGroup>
111111

112-
<!--Enabled Shopping Cart Sidebar -->
112+
<!--Enabled Mini Cart -->
113113
<magentoCLI stepKey="enableShoppingCartSidebar" command="config:set checkout/sidebar/display 1"/>
114114
<magentoCLI command="cache:flush" stepKey="flushCache"/>
115115
<reloadPage stepKey="reloadThePage"/>

app/code/Magento/Checkout/etc/adminhtml/system.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
</field>
5858
</group>
5959
<group id="sidebar" translate="label" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1">
60-
<label>Shopping Cart Sidebar</label>
60+
<label>Mini Cart</label>
6161
<field id="display" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
62-
<label>Display Shopping Cart Sidebar</label>
62+
<label>Display Mini Cart</label>
6363
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
6464
</field>
6565
<field id="count" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">

app/code/Magento/Checkout/i18n/en_US.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ Shipping,Shipping
156156
"Number of Items to Display Pager","Number of Items to Display Pager"
157157
"My Cart Link","My Cart Link"
158158
"Display Cart Summary","Display Cart Summary"
159-
"Shopping Cart Sidebar","Shopping Cart Sidebar"
160-
"Display Shopping Cart Sidebar","Display Shopping Cart Sidebar"
159+
"Mini Cart","Mini Cart"
160+
"Display Mini Cart","Display Mini Cart"
161161
"Number of Items to Display Scrollbar","Number of Items to Display Scrollbar"
162162
"Maximum Number of Items to Display","Maximum Number of Items to Display"
163163
"Payment Failed Emails","Payment Failed Emails"

app/code/Magento/LayeredNavigation/Block/Navigation.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ public function getFilters()
121121
*/
122122
public function canShowBlock()
123123
{
124-
return $this->visibilityFlag->isEnabled($this->getLayer(), $this->getFilters());
124+
return $this->getLayer()->getCurrentCategory()->getDisplayMode() !== \Magento\Catalog\Model\Category::DM_PAGE
125+
&& $this->visibilityFlag->isEnabled($this->getLayer(), $this->getFilters());
125126
}
126127

127128
/**

app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\LayeredNavigation\Test\Unit\Block;
88

9+
use Magento\Catalog\Model\Category;
10+
911
class NavigationTest extends \PHPUnit\Framework\TestCase
1012
{
1113
/**
@@ -98,9 +100,61 @@ public function testCanShowBlock()
98100
->method('isEnabled')
99101
->with($this->catalogLayerMock, $filters)
100102
->will($this->returnValue($enabled));
103+
104+
$category = $this->createMock(Category::class);
105+
$this->catalogLayerMock->expects($this->atLeastOnce())->method('getCurrentCategory')->willReturn($category);
106+
$category->expects($this->once())->method('getDisplayMode')->willReturn(Category::DM_PRODUCT);
107+
101108
$this->assertEquals($enabled, $this->model->canShowBlock());
102109
}
103110

111+
/**
112+
* Test canShowBlock() with different category display types.
113+
*
114+
* @param string $mode
115+
* @param bool $result
116+
*
117+
* @dataProvider canShowBlockDataProvider
118+
*/
119+
public function testCanShowBlockWithDifferentDisplayModes(string $mode, bool $result)
120+
{
121+
$filters = ['To' => 'be', 'or' => 'not', 'to' => 'be'];
122+
123+
$this->filterListMock->expects($this->atLeastOnce())->method('getFilters')
124+
->with($this->catalogLayerMock)
125+
->will($this->returnValue($filters));
126+
$this->assertEquals($filters, $this->model->getFilters());
127+
128+
$this->visibilityFlagMock
129+
->expects($this->any())
130+
->method('isEnabled')
131+
->with($this->catalogLayerMock, $filters)
132+
->will($this->returnValue(true));
133+
134+
$category = $this->createMock(Category::class);
135+
$this->catalogLayerMock->expects($this->atLeastOnce())->method('getCurrentCategory')->willReturn($category);
136+
$category->expects($this->once())->method('getDisplayMode')->willReturn($mode);
137+
$this->assertEquals($result, $this->model->canShowBlock());
138+
}
139+
140+
public function canShowBlockDataProvider()
141+
{
142+
return [
143+
[
144+
Category::DM_PRODUCT,
145+
true,
146+
],
147+
[
148+
Category::DM_PAGE,
149+
false,
150+
],
151+
[
152+
Category::DM_MIXED,
153+
true,
154+
],
155+
];
156+
}
157+
104158
public function testGetClearUrl()
105159
{
106160
$this->filterListMock->expects($this->any())->method('getFilters')->will($this->returnValue([]));

app/code/Magento/Sales/view/adminhtml/templates/items/column/name.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<?php $_option = $block->getFormattedOption($_option['value']); ?>
3030
<?php $dots = 'dots' . uniqid(); ?>
3131
<?php $id = 'id' . uniqid(); ?>
32-
<?= $block->escapeHtml($_option['value'], ['a']) ?><?php if (isset($_option['remainder']) && $_option['remainder']) : ?><span id="<?= /* @noEscape */ $dots; ?>"> ...</span><span id="<?= /* @noEscape */ $id; ?>"><?= $block->escapeHtml($_option['remainder'], ['a']) ?></span>
32+
<?= $block->escapeHtml($_option['value'], ['a', 'br']) ?><?php if (isset($_option['remainder']) && $_option['remainder']) : ?><span id="<?= /* @noEscape */ $dots; ?>"> ...</span><span id="<?= /* @noEscape */ $id; ?>"><?= $block->escapeHtml($_option['remainder'], ['a']) ?></span>
3333
<script>
3434
require(['prototype'], function() {
3535
$('<?= /* @noEscape */ $id; ?>').hide();
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
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\SalesRule\Test\Unit\Observer;
9+
10+
use Magento\Framework\Api\SearchCriteria;
11+
use Magento\Framework\Api\SearchCriteriaBuilder;
12+
use Magento\Framework\DataObject;
13+
use Magento\Framework\Event\Observer;
14+
use Magento\Quote\Api\CartRepositoryInterface;
15+
use Magento\Quote\Model\Quote;
16+
use Magento\SalesRule\Api\Exception\CodeRequestLimitException;
17+
use Magento\SalesRule\Model\Spi\CodeLimitManagerInterface;
18+
use Magento\SalesRule\Observer\CouponCodeValidation;
19+
use PHPUnit\Framework\TestCase;
20+
use PHPUnit_Framework_MockObject_MockObject;
21+
22+
/**
23+
* Class CouponCodeValidationTest
24+
*/
25+
class CouponCodeValidationTest extends TestCase
26+
{
27+
/**
28+
* @var CouponCodeValidation
29+
*/
30+
private $couponCodeValidation;
31+
32+
/**
33+
* @var PHPUnit_Framework_MockObject_MockObject|CodeLimitManagerInterface
34+
*/
35+
private $codeLimitManagerMock;
36+
37+
/**
38+
* @var PHPUnit_Framework_MockObject_MockObject|CartRepositoryInterface
39+
*/
40+
private $cartRepositoryMock;
41+
42+
/**
43+
* @var PHPUnit_Framework_MockObject_MockObject|SearchCriteriaBuilder
44+
*/
45+
private $searchCriteriaBuilderMock;
46+
47+
/**
48+
* @var PHPUnit_Framework_MockObject_MockObject|Observer
49+
*/
50+
private $observerMock;
51+
52+
/**
53+
* @var PHPUnit_Framework_MockObject_MockObject
54+
*/
55+
private $searchCriteriaMock;
56+
57+
/**
58+
* @var PHPUnit_Framework_MockObject_MockObject
59+
*/
60+
private $quoteMock;
61+
62+
/**
63+
* Set Up
64+
*/
65+
protected function setUp()
66+
{
67+
$this->codeLimitManagerMock = $this->createMock(CodeLimitManagerInterface::class);
68+
$this->observerMock = $this->createMock(Observer::class);
69+
$this->searchCriteriaMock = $this->getMockBuilder(SearchCriteria::class)
70+
->disableOriginalConstructor()->getMockForAbstractClass();
71+
$this->cartRepositoryMock = $this->getMockBuilder(CartRepositoryInterface::class)
72+
->setMethods(['getItems'])
73+
->disableOriginalConstructor()->getMockForAbstractClass();
74+
$this->searchCriteriaBuilderMock = $this->getMockBuilder(SearchCriteriaBuilder::class)
75+
->setMethods(['addFilter', 'create'])
76+
->disableOriginalConstructor()->getMockForAbstractClass();
77+
$this->quoteMock = $this->createPartialMock(
78+
Quote::class,
79+
['getCouponCode', 'setCouponCode', 'getId']
80+
);
81+
82+
$this->couponCodeValidation = new CouponCodeValidation(
83+
$this->codeLimitManagerMock,
84+
$this->cartRepositoryMock,
85+
$this->searchCriteriaBuilderMock
86+
);
87+
}
88+
89+
/**
90+
* Testing the coupon code that haven't reached the request limit
91+
*/
92+
public function testCouponCodeNotReachedTheLimit()
93+
{
94+
$couponCode = 'AB123';
95+
$this->observerMock->expects($this->once())->method('getData')->with('quote')
96+
->willReturn($this->quoteMock);
97+
$this->quoteMock->expects($this->once())->method('getCouponCode')->willReturn($couponCode);
98+
$this->searchCriteriaBuilderMock->expects($this->once())->method('addFilter')->willReturnSelf();
99+
$this->searchCriteriaBuilderMock->expects($this->once())->method('create')
100+
->willReturn($this->searchCriteriaMock);
101+
$this->quoteMock->expects($this->once())->method('getId')->willReturn(123);
102+
$this->cartRepositoryMock->expects($this->any())->method('getList')->willReturnSelf();
103+
$this->cartRepositoryMock->expects($this->any())->method('getItems')->willReturn([]);
104+
$this->codeLimitManagerMock->expects($this->once())->method('checkRequest')->with($couponCode);
105+
$this->quoteMock->expects($this->never())->method('setCouponCode')->with('');
106+
107+
$this->couponCodeValidation->execute($this->observerMock);
108+
}
109+
110+
/**
111+
* Testing with the changed coupon code
112+
*/
113+
public function testCouponCodeNotReachedTheLimitWithNewCouponCode()
114+
{
115+
$couponCode = 'AB123';
116+
$newCouponCode = 'AB234';
117+
118+
$this->observerMock->expects($this->once())->method('getData')->with('quote')
119+
->willReturn($this->quoteMock);
120+
$this->quoteMock->expects($this->once())->method('getCouponCode')->willReturn($couponCode);
121+
$this->searchCriteriaBuilderMock->expects($this->once())->method('addFilter')->willReturnSelf();
122+
$this->searchCriteriaBuilderMock->expects($this->once())->method('create')
123+
->willReturn($this->searchCriteriaMock);
124+
$this->quoteMock->expects($this->once())->method('getId')->willReturn(123);
125+
$this->cartRepositoryMock->expects($this->any())->method('getList')->willReturnSelf();
126+
$this->cartRepositoryMock->expects($this->any())->method('getItems')
127+
->willReturn([new DataObject(['coupon_code' => $newCouponCode])]);
128+
$this->codeLimitManagerMock->expects($this->once())->method('checkRequest')->with($couponCode);
129+
$this->quoteMock->expects($this->never())->method('setCouponCode')->with('');
130+
131+
$this->couponCodeValidation->execute($this->observerMock);
132+
}
133+
134+
/**
135+
* Testing the coupon code that reached the request limit
136+
*
137+
* @expectedException \Magento\SalesRule\Api\Exception\CodeRequestLimitException
138+
* @expectedExceptionMessage Too many coupon code requests, please try again later.
139+
*/
140+
public function testReachingLimitForCouponCode()
141+
{
142+
$couponCode = 'AB123';
143+
$this->observerMock->expects($this->once())->method('getData')->with('quote')
144+
->willReturn($this->quoteMock);
145+
$this->quoteMock->expects($this->once())->method('getCouponCode')->willReturn($couponCode);
146+
$this->searchCriteriaBuilderMock->expects($this->once())->method('addFilter')->willReturnSelf();
147+
$this->searchCriteriaBuilderMock->expects($this->once())->method('create')
148+
->willReturn($this->searchCriteriaMock);
149+
$this->quoteMock->expects($this->once())->method('getId')->willReturn(123);
150+
$this->cartRepositoryMock->expects($this->any())->method('getList')->willReturnSelf();
151+
$this->cartRepositoryMock->expects($this->any())->method('getItems')->willReturn([]);
152+
$this->codeLimitManagerMock->expects($this->once())->method('checkRequest')->with($couponCode)
153+
->willThrowException(
154+
new CodeRequestLimitException(__('Too many coupon code requests, please try again later.'))
155+
);
156+
$this->quoteMock->expects($this->once())->method('setCouponCode')->with('');
157+
158+
$this->couponCodeValidation->execute($this->observerMock);
159+
}
160+
161+
/**
162+
* Testing the quote that doesn't have a coupon code set
163+
*/
164+
public function testQuoteWithNoCouponCode()
165+
{
166+
$couponCode = null;
167+
$this->observerMock->expects($this->once())->method('getData')->with('quote')
168+
->willReturn($this->quoteMock);
169+
$this->quoteMock->expects($this->once())->method('getCouponCode')->willReturn($couponCode);
170+
$this->quoteMock->expects($this->never())->method('getId')->willReturn(123);
171+
$this->quoteMock->expects($this->never())->method('setCouponCode')->with('');
172+
173+
$this->couponCodeValidation->execute($this->observerMock);
174+
}
175+
}

0 commit comments

Comments
 (0)