Skip to content

Commit 3a2c177

Browse files
author
Stanislav Idolov
authored
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #17739: Search: Add unit test for PopularSearchTerms model (by @dmytro-ch) - #17876: Sales: Add unit test for validator model class (by @dmytro-ch) - #17877: Resolved : Wishlist icon cut on Shopping cart page in mobile view #17851 (by @hitesh-wagento) - #17773: Fix for ProductLink - setterName was incorrectly being set (by @insanityinside) - #17385: Remove leading Countrycode from EU-VAT-Numbers (by @Drischie) Fixed GitHub Issues: - #17851: Wishlist icon cut on Shopping cart page in mobile view (reported by @hitesh-wagento) has been fixed in #17877 by @hitesh-wagento in 2.2-develop branch Related commits: 1. 2139fec
2 parents ef55fa7 + cb2d5c0 commit 3a2c177

File tree

6 files changed

+242
-5
lines changed

6 files changed

+242
-5
lines changed

app/code/Magento/Catalog/Model/ProductLink/Repository.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Catalog\Api\Data\ProductLinkExtensionFactory;
1111
use Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks as LinksInitializer;
1212
use Magento\Catalog\Model\Product\LinkTypeProvider;
13+
use Magento\Framework\Api\SimpleDataObjectConverter;
1314
use Magento\Framework\Exception\CouldNotSaveException;
1415
use Magento\Framework\Exception\NoSuchEntityException;
1516
use Magento\Framework\EntityManager\MetadataPool;
@@ -170,7 +171,7 @@ public function getList(\Magento\Catalog\Api\Data\ProductInterface $product)
170171
foreach ($item['custom_attributes'] as $option) {
171172
$name = $option['attribute_code'];
172173
$value = $option['value'];
173-
$setterName = 'set'.ucfirst($name);
174+
$setterName = 'set' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($name);
174175
// Check if setter exists
175176
if (method_exists($productLinkExtension, $setterName)) {
176177
call_user_func([$productLinkExtension, $setterName], $value);

app/code/Magento/Customer/Model/Vat.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,15 @@ public function checkVatNumber($countryCode, $vatNumber, $requesterCountryCode =
184184

185185
$requestParams = [];
186186
$requestParams['countryCode'] = $countryCode;
187-
$requestParams['vatNumber'] = str_replace([' ', '-'], ['', ''], $vatNumber);
187+
$vatNumberSanitized = $this->isCountryInEU($countryCode)
188+
? str_replace([' ', '-', $countryCode], ['', '', ''], $vatNumber)
189+
: str_replace([' ', '-'], ['', ''], $vatNumber);
190+
$requestParams['vatNumber'] = $vatNumberSanitized;
188191
$requestParams['requesterCountryCode'] = $requesterCountryCode;
189-
$requestParams['requesterVatNumber'] = str_replace([' ', '-'], ['', ''], $requesterVatNumber);
190-
192+
$reqVatNumSanitized = $this->isCountryInEU($requesterCountryCode)
193+
? str_replace([' ', '-', $requesterCountryCode], ['', '', ''], $requesterVatNumber)
194+
: str_replace([' ', '-'], ['', ''], $requesterVatNumber);
195+
$requestParams['requesterVatNumber'] = $reqVatNumSanitized;
191196
// Send request to service
192197
$result = $soapClient->checkVatApprox($requestParams);
193198

app/code/Magento/GroupedProduct/Model/Product/Initialization/Helper/ProductLinks/Plugin/Grouped.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Catalog\Api\Data\ProductLinkExtensionFactory;
99
use Magento\Catalog\Api\Data\ProductLinkInterfaceFactory;
1010
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Framework\Api\SimpleDataObjectConverter;
1112
use Magento\Framework\Exception\NoSuchEntityException;
1213
use Magento\GroupedProduct\Model\Product\Type\Grouped as TypeGrouped;
1314

@@ -111,7 +112,7 @@ public function beforeInitializeLinks(
111112
foreach ($linkRaw['custom_attributes'] as $option) {
112113
$name = $option['attribute_code'];
113114
$value = $option['value'];
114-
$setterName = 'set' . ucfirst($name);
115+
$setterName = 'set' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($name);
115116
// Check if setter exists
116117
if (method_exists($productLinkExtension, $setterName)) {
117118
call_user_func([$productLinkExtension, $setterName], $value);
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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\Sales\Test\Unit\Model;
9+
10+
use Magento\Framework\DataObject;
11+
use Magento\Framework\Exception\ConfigurationMismatchException;
12+
use Magento\Framework\ObjectManagerInterface;
13+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
14+
use Magento\Sales\Api\Data\OrderInterface;
15+
use Magento\Sales\Model\Validator;
16+
use Magento\Sales\Model\ValidatorInterface;
17+
use Magento\Sales\Model\ValidatorResultInterface;
18+
use Magento\Sales\Model\ValidatorResultInterfaceFactory;
19+
20+
/**
21+
* @covers \Magento\Sales\Model\Validator
22+
*/
23+
class ValidatorTest extends \PHPUnit\Framework\TestCase
24+
{
25+
/**
26+
* Testable Object
27+
*
28+
* @var Validator
29+
*/
30+
private $validator;
31+
32+
/**
33+
* Object Manager
34+
*
35+
* @var ObjectManager
36+
*/
37+
private $objectManager;
38+
39+
/**
40+
* @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
41+
*/
42+
private $objectManagerMock;
43+
44+
/**
45+
* @var ValidatorResultInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
46+
*/
47+
private $validatorResultFactoryMock;
48+
49+
/**
50+
* @var ValidatorResultInterface|\PHPUnit_Framework_MockObject_MockObject
51+
*/
52+
private $validatorResultMock;
53+
54+
/**
55+
* @var ValidatorInterface|\PHPUnit_Framework_MockObject_MockObject
56+
*/
57+
private $validatorMock;
58+
59+
/**
60+
* @var OrderInterface|\PHPUnit_Framework_MockObject_MockObject
61+
*/
62+
private $entityMock;
63+
64+
/**
65+
* Set Up
66+
*
67+
* @return void
68+
*/
69+
protected function setUp()
70+
{
71+
$this->objectManagerMock = $this->createMock(ObjectManagerInterface::class);
72+
$this->entityMock = $this->createMock(OrderInterface::class);
73+
$this->validatorMock = $this->createMock(ValidatorInterface::class);
74+
$this->validatorResultFactoryMock = $this->getMockBuilder(ValidatorResultInterfaceFactory::class)
75+
->setMethods(['create'])->disableOriginalConstructor()->getMock();
76+
$this->validatorResultMock = $this->createMock(ValidatorResultInterface::class);
77+
$this->validatorResultFactoryMock->expects($this->any())->method('create')
78+
->willReturn($this->validatorResultMock);
79+
$this->objectManager = new ObjectManager($this);
80+
$this->validator = $this->objectManager->getObject(
81+
Validator::class,
82+
[
83+
'objectManager' => $this->objectManagerMock,
84+
'validatorResult' => $this->validatorResultFactoryMock,
85+
]
86+
);
87+
}
88+
89+
/**
90+
* Test validate method
91+
*
92+
* @return void
93+
*
94+
* @throws ConfigurationMismatchException
95+
*/
96+
public function testValidate()
97+
{
98+
$validatorName = 'test';
99+
$validators = [$validatorName];
100+
$context = new DataObject();
101+
$validatorArguments = ['context' => $context];
102+
$message = __('Sample message.');
103+
$messages = [$message];
104+
105+
$this->objectManagerMock->expects($this->once())->method('create')
106+
->with($validatorName, $validatorArguments)->willReturn($this->validatorMock);
107+
$this->validatorMock->expects($this->once())->method('validate')->with($this->entityMock)
108+
->willReturn($messages);
109+
$this->validatorResultMock->expects($this->once())->method('addMessage')->with($message);
110+
111+
$expected = $this->validatorResultMock;
112+
$actual = $this->validator->validate($this->entityMock, $validators, $context);
113+
$this->assertEquals($expected, $actual);
114+
}
115+
116+
/**
117+
* Test validate method
118+
*
119+
* @return void
120+
*
121+
* @throws ConfigurationMismatchException
122+
*/
123+
public function testValidateWithException()
124+
{
125+
$validatorName = 'test';
126+
$validators = [$validatorName];
127+
$this->objectManagerMock->expects($this->once())->method('create')->willReturn(null);
128+
$this->validatorResultMock->expects($this->never())->method('addMessage');
129+
$this->expectException(ConfigurationMismatchException::class);
130+
$this->validator->validate($this->entityMock, $validators);
131+
}
132+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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\Search\Test\Unit\Model;
9+
10+
use Magento\Framework\App\Config\ScopeConfigInterface;
11+
use Magento\Search\Model\PopularSearchTerms;
12+
use Magento\Search\Model\ResourceModel\Query\Collection;
13+
use Magento\Store\Model\ScopeInterface;
14+
15+
/**
16+
* @covers \Magento\Search\Model\PopularSearchTerms
17+
*/
18+
class PopularSearchTermsTest extends \PHPUnit\Framework\TestCase
19+
{
20+
/**
21+
* Testable Object
22+
*
23+
* @var PopularSearchTerms
24+
*/
25+
private $popularSearchTerms;
26+
27+
/**
28+
* @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
29+
*/
30+
private $scopeConfigMock;
31+
32+
/**
33+
* @var Collection|\PHPUnit_Framework_MockObject_MockObject
34+
*/
35+
private $queryCollectionMock;
36+
37+
/**
38+
* Set Up
39+
*
40+
* @return void
41+
*/
42+
protected function setUp()
43+
{
44+
$this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
45+
$this->queryCollectionMock = $this->createMock(Collection::class);
46+
$this->popularSearchTerms = new PopularSearchTerms($this->scopeConfigMock, $this->queryCollectionMock);
47+
}
48+
49+
/**
50+
* Test isCacheableDataProvider method
51+
*
52+
* @dataProvider isCacheableDataProvider
53+
*
54+
* @param string $term
55+
* @param array $terms
56+
* @param $expected $terms
57+
*
58+
* @return void
59+
*/
60+
public function testIsCacheable($term, $terms, $expected)
61+
{
62+
$storeId = 7;
63+
$pageSize = 25;
64+
65+
$this->scopeConfigMock->expects($this->once())->method('getValue')
66+
->with(
67+
PopularSearchTerms::XML_PATH_MAX_COUNT_CACHEABLE_SEARCH_TERMS,
68+
ScopeInterface::SCOPE_STORE,
69+
$storeId
70+
)->willReturn($pageSize);
71+
$this->queryCollectionMock->expects($this->once())->method('setPopularQueryFilter')->with($storeId)
72+
->willReturnSelf();
73+
$this->queryCollectionMock->expects($this->once())->method('setPageSize')->with($pageSize)
74+
->willReturnSelf();
75+
$this->queryCollectionMock->expects($this->once())->method('load')->willReturnSelf();
76+
$this->queryCollectionMock->expects($this->once())->method('getColumnValues')->with('query_text')
77+
->willReturn($terms);
78+
79+
$actual = $this->popularSearchTerms->isCacheable($term, $storeId);
80+
self::assertEquals($expected, $actual);
81+
}
82+
83+
/**
84+
* @return array
85+
*/
86+
public function isCacheableDataProvider()
87+
{
88+
return [
89+
['test01', [], false],
90+
['test02', ['test01', 'test02'], true],
91+
['test03', ['test01', 'test02'], false],
92+
['test04', ['test04'], true],
93+
];
94+
}
95+
}

app/design/frontend/Magento/luma/Magento_Wishlist/web/css/source/_module.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@
277277
@_icon-font-color-hover: @primary__color,
278278
@_icon-font-color-active: @minicart-icons-color
279279
);
280+
&:before {
281+
overflow: visible;
282+
}
280283
}
281284
}
282285
}

0 commit comments

Comments
 (0)