Skip to content

Commit ad6c093

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop latest changes
Accepted Community Pull Requests: - #26016: [DownloadableImportExport] Cover Helper Data by Unit Test (by @edenduong) - #25975: phpdoc fix return type (by @maslii) - #25114: Added translate for strings and added missing node in existing translate attribute on xml. (by @sanganinamrata) - #25992: Cover #25556 with jasmine test (by @Nazar65) - #25997: [Newsletter] Refactor code and Cover Model/Observer class by Unit Test (by @edenduong) - #25993: [InstantPurchase] Cover Ui/CustomerAddressesFormatter and Ui/ShippingMethodFormatter by Unit Test (by @edenduong) - #25973: [Removed spacing in submenu on hover desktop] (by @hitesh-wagento) - #25624: Add right arrow to show some items have children (by @fredden) Fixed GitHub Issues: - #25972: Not required spacing in submenu on hover desktop (reported by @hitesh-wagento) has been fixed in #25973 by @hitesh-wagento in 2.4-develop branch Related commits: 1. 200f518
2 parents 21c59de + 9cb4235 commit ad6c093

File tree

14 files changed

+558
-17
lines changed

14 files changed

+558
-17
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<field id="search_suggestion_enabled">1</field>
6161
</depends>
6262
</field>
63-
<field id="search_suggestion_count_results_enabled" translate="label" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="1">
63+
<field id="search_suggestion_count_results_enabled" translate="label comment" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="1">
6464
<label>Show Results Count for Each Suggestion</label>
6565
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
6666
<comment>When you enable this option your site may slow down.</comment>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<frontend_model>Magento\Analytics\Block\Adminhtml\System\Config\CollectionTimeLabel</frontend_model>
3030
<backend_model>Magento\Analytics\Model\Config\Backend\CollectionTime</backend_model>
3131
</field>
32-
<field id="vertical" translate="label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
32+
<field id="vertical" translate="hint label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
3333
<hint>Industry Data</hint>
3434
<label>Industry</label>
3535
<comment>In order to personalize your Advanced Reporting experience, please select your industry.</comment>

app/code/Magento/AsynchronousOperations/view/adminhtml/ui_component/bulk_listing.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<actionsColumn name="actions" class="\Magento\AsynchronousOperations\Ui\Component\Listing\Column\Actions">
9393
<settings>
9494
<indexField>id</indexField>
95-
<label>Action</label>
95+
<label translate="true">Action</label>
9696
</settings>
9797
</actionsColumn>
9898
</columns>

app/code/Magento/Customer/Controller/Account/CreatePost.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public function validateForCsrf(RequestInterface $request): ?bool
327327
/**
328328
* Create customer account action
329329
*
330-
* @return void
330+
* @return \Magento\Framework\Controller\Result\Redirect
331331
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
332332
* @SuppressWarnings(PHPMD.NPathComplexity)
333333
*/
Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\DownloadableImportExport\Test\Unit\Helper;
10+
11+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
12+
use Magento\DownloadableImportExport\Helper\Data as HelperData;
13+
use Magento\DownloadableImportExport\Model\Import\Product\Type\Downloadable;
14+
use PHPUnit\Framework\TestCase;
15+
16+
class DataTest extends TestCase
17+
{
18+
/**
19+
* @var HelperData
20+
*/
21+
private $helper;
22+
23+
/**
24+
* Setup environment for test
25+
*/
26+
protected function setUp()
27+
{
28+
$objectManagerHelper = new ObjectManagerHelper($this);
29+
$this->helper = $objectManagerHelper->getObject(HelperData::class);
30+
}
31+
32+
/**
33+
* Test isRowDownloadableEmptyOptions with dataProvider
34+
*
35+
* @param array $rowData
36+
* @param bool $expected
37+
* @dataProvider isRowDownloadableEmptyOptionsDataProvider
38+
*/
39+
public function testIsRowDownloadableEmptyOptions($rowData, $expected)
40+
{
41+
$this->assertEquals($expected, $this->helper->isRowDownloadableEmptyOptions($rowData));
42+
}
43+
44+
/**
45+
* Data Provider to test isRowDownloadableEmptyOptions
46+
*
47+
* @return array
48+
*/
49+
public function isRowDownloadableEmptyOptionsDataProvider()
50+
{
51+
return [
52+
'Data set include downloadable link and sample' => [
53+
[
54+
Downloadable::COL_DOWNLOADABLE_LINKS => 'https://magento2.com/download_link',
55+
Downloadable::COL_DOWNLOADABLE_SAMPLES => 'https://magento2.com/sample_link'
56+
],
57+
false
58+
],
59+
'Data set with empty' => [
60+
[
61+
Downloadable::COL_DOWNLOADABLE_LINKS => '',
62+
Downloadable::COL_DOWNLOADABLE_SAMPLES => ''
63+
],
64+
true
65+
]
66+
];
67+
}
68+
69+
/**
70+
* Test isRowDownloadableNoValid with dataProvider
71+
*
72+
* @param array $rowData
73+
* @param bool $expected
74+
* @dataProvider isRowDownloadableNoValidDataProvider
75+
*/
76+
public function isRowDownloadableNoValid($rowData, $expected)
77+
{
78+
$this->assertEquals($expected, $this->helper->isRowDownloadableNoValid($rowData));
79+
}
80+
81+
/**
82+
* Data Provider to test isRowDownloadableEmptyOptions
83+
*
84+
* @return array
85+
*/
86+
public function isRowDownloadableNoValidDataProvider()
87+
{
88+
return [
89+
'Data set include downloadable link and sample' => [
90+
[
91+
Downloadable::COL_DOWNLOADABLE_LINKS => 'https://magento2.com/download_link',
92+
Downloadable::COL_DOWNLOADABLE_SAMPLES => 'https://magento2.com/sample_link'
93+
],
94+
true
95+
],
96+
'Data set with empty' => [
97+
[
98+
Downloadable::COL_DOWNLOADABLE_LINKS => '',
99+
Downloadable::COL_DOWNLOADABLE_SAMPLES => ''
100+
],
101+
false
102+
]
103+
];
104+
}
105+
106+
/**
107+
* Test fillExistOptions with dataProvider
108+
*
109+
* @param array $base
110+
* @param array $option
111+
* @param array $existingOptions
112+
* @param array $expected
113+
* @dataProvider fillExistOptionsDataProvider
114+
*/
115+
public function testFillExistOptions($base, $option, $existingOptions, $expected)
116+
{
117+
$this->assertEquals($expected, $this->helper->fillExistOptions($base, $option, $existingOptions));
118+
}
119+
120+
/**
121+
* Data Provider to test fillExistOptions
122+
*
123+
* @return array
124+
*/
125+
public function fillExistOptionsDataProvider()
126+
{
127+
return [
128+
'Data set 1' => [
129+
[],
130+
[
131+
'product_id' => 1,
132+
'sample_type' => 'sample_type1',
133+
'sample_url' => 'sample_url1',
134+
'sample_file' => 'sample_file1',
135+
'link_file' => 'link_file1',
136+
'link_type' => 'link_type1',
137+
'link_url' => 'link_url1'
138+
],
139+
[
140+
[
141+
'product_id' => 1,
142+
'sample_type' => 'sample_type1',
143+
'sample_url' => 'sample_url1',
144+
'sample_file' => 'sample_file1',
145+
'link_file' => 'link_file1',
146+
'link_type' => 'link_type1',
147+
'link_url' => 'link_url1'
148+
],
149+
[
150+
'product_id' => 2,
151+
'sample_type' => 'sample_type2',
152+
'sample_url' => 'sample_url2',
153+
'sample_file' => 'sample_file2',
154+
'link_file' => 'link_file2',
155+
'link_type' => 'link_type2',
156+
'link_url' => 'link_url2'
157+
]
158+
],
159+
[
160+
'product_id' => 1,
161+
'sample_type' => 'sample_type1',
162+
'sample_url' => 'sample_url1',
163+
'sample_file' => 'sample_file1',
164+
'link_file' => 'link_file1',
165+
'link_type' => 'link_type1',
166+
'link_url' => 'link_url1'
167+
]
168+
],
169+
'Data set 2' => [
170+
[],
171+
[
172+
'product_id' => 1,
173+
'sample_type' => 'sample_type1',
174+
'sample_url' => 'sample_url1',
175+
'sample_file' => 'sample_file1',
176+
'link_file' => 'link_file1',
177+
'link_type' => 'link_type1',
178+
'link_url' => 'link_url1'
179+
],
180+
[],
181+
[]
182+
]
183+
];
184+
}
185+
186+
/**
187+
* Test prepareDataForSave with dataProvider
188+
*
189+
* @param array $base
190+
* @param array $replacement
191+
* @param array $expected
192+
* @dataProvider prepareDataForSaveDataProvider
193+
*/
194+
public function testPrepareDataForSave($base, $replacement, $expected)
195+
{
196+
$this->assertEquals($expected, $this->helper->prepareDataForSave($base, $replacement));
197+
}
198+
199+
/**
200+
* Data Provider to test prepareDataForSave
201+
*
202+
* @return array
203+
*/
204+
public function prepareDataForSaveDataProvider()
205+
{
206+
return [
207+
'Data set 1' => [
208+
[],
209+
[],
210+
[]
211+
],
212+
213+
'Data set 2' => [
214+
[
215+
'product_id' => 1,
216+
'sample_type' => 'sample_type1',
217+
'sample_url' => 'sample_url1',
218+
'sample_file' => 'sample_file1',
219+
'link_file' => 'link_file1',
220+
'link_type' => 'link_type1',
221+
'link_url' => 'link_url1'
222+
],
223+
[
224+
[
225+
'product_id' => 2,
226+
'sample_type' => 'sample_type2',
227+
'sample_url' => 'sample_url2',
228+
'sample_file' => 'sample_file2',
229+
'link_file' => 'link_file2',
230+
'link_type' => 'link_type2',
231+
'link_url' => 'link_url2'
232+
]
233+
],
234+
[
235+
[
236+
'product_id' => 2,
237+
'sample_type' => 'sample_type2',
238+
'sample_url' => 'sample_url2',
239+
'sample_file' => 'sample_file2',
240+
'link_file' => 'link_file2',
241+
'link_type' => 'link_type2',
242+
'link_url' => 'link_url2'
243+
]
244+
]
245+
]
246+
];
247+
}
248+
249+
/**
250+
* Test getTypeByValue with dataProvider
251+
*
252+
* @param string $option
253+
* @param string $expected
254+
* @dataProvider getTypeByValueDataProvider
255+
*/
256+
public function testGetTypeByValue($option, $expected)
257+
{
258+
$this->assertEquals($expected, $this->helper->getTypeByValue($option));
259+
}
260+
261+
/**
262+
* Data Provider for getTypeByValue
263+
*
264+
* @return array
265+
*/
266+
public function getTypeByValueDataProvider()
267+
{
268+
return [
269+
'Case File Option Value' => [
270+
'file1',
271+
Downloadable::FILE_OPTION_VALUE
272+
],
273+
'Case url Option Value' => [
274+
'https://example.com',
275+
Downloadable::URL_OPTION_VALUE
276+
]
277+
];
278+
}
279+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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\InstantPurchase\Test\Unit\Model\Ui;
9+
10+
use Magento\InstantPurchase\Model\Ui\CustomerAddressesFormatter;
11+
use Magento\Customer\Model\Address;
12+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
13+
use Magento\Directory\Model\Country;
14+
use PHPUnit\Framework\TestCase;
15+
16+
class CustomerAddressesFormatterTest extends TestCase
17+
{
18+
/**
19+
* @var CustomerAddressesFormatter|\PHPUnit_Framework_MockObject_MockObject
20+
*/
21+
private $customerAddressesFormatter;
22+
23+
/**
24+
* Setup environment for testing
25+
*/
26+
protected function setUp()
27+
{
28+
$objectManager = new ObjectManagerHelper($this);
29+
$this->customerAddressesFormatter = $objectManager->getObject(CustomerAddressesFormatter::class);
30+
}
31+
32+
/**
33+
* Test format()
34+
*/
35+
public function testFormat()
36+
{
37+
$addressMock = $this->createPartialMock(
38+
Address::class,
39+
['getName', 'getStreetFull', 'getCity', 'getRegion', 'getPostcode', 'getCountryModel']
40+
);
41+
$countryMock = $this->createMock(Country::class);
42+
43+
$countryMock->expects($this->any())->method('getName')->willReturn('USA');
44+
$addressMock->expects($this->any())->method('getName')->willReturn('Address Name');
45+
$addressMock->expects($this->any())->method('getStreetFull')->willReturn('Address Street Full');
46+
$addressMock->expects($this->any())->method('getCity')->willReturn('Address City');
47+
$addressMock->expects($this->any())->method('getRegion')->willReturn('California');
48+
$addressMock->expects($this->any())->method('getPostcode')->willReturn('12345');
49+
$addressMock->expects($this->any())->method('getCountryModel')->willReturn($countryMock);
50+
51+
$this->assertEquals(
52+
'Address Name, Address Street Full, Address City, California 12345, USA',
53+
$this->customerAddressesFormatter->format($addressMock)
54+
);
55+
}
56+
}

0 commit comments

Comments
 (0)