Skip to content

Commit 9e8955c

Browse files
authored
Merge pull request #4347 from magento-tsg-csl3/2.2-develop-pr32
[TSG-CSL3] For 2.2 (pr32)
2 parents 308b9c0 + bb8c85b commit 9e8955c

File tree

11 files changed

+363
-68
lines changed

11 files changed

+363
-68
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool;
2828
use Magento\Ui\Component\Form\Field;
2929
use Magento\Ui\DataProvider\EavValidationRules;
30+
use Magento\Ui\Component\Form\Element\Multiline;
3031

3132
/**
3233
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -568,8 +569,14 @@ protected function prepareAddressData($addressId, array &$addresses, array $cust
568569
) {
569570
$addresses[$addressId]['default_shipping'] = $customer['default_shipping'];
570571
}
571-
if (isset($addresses[$addressId]['street']) && !is_array($addresses[$addressId]['street'])) {
572-
$addresses[$addressId]['street'] = explode("\n", $addresses[$addressId]['street']);
572+
573+
foreach ($this->meta['address']['children'] as $attributeName => $attributeMeta) {
574+
if ($attributeMeta['arguments']['data']['config']['dataType'] === Multiline::NAME
575+
&& isset($addresses[$addressId][$attributeName])
576+
&& !\is_array($addresses[$addressId][$attributeName])
577+
) {
578+
$addresses[$addressId][$attributeName] = explode("\n", $addresses[$addressId][$attributeName]);
579+
}
573580
}
574581
}
575582

app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,25 @@ public function getAttributesMetaDataProvider()
249249
],
250250
],
251251
],
252-
]
252+
],
253+
'street' => [
254+
'arguments' => [
255+
'data' => [
256+
'config' => [
257+
'dataType' => 'multiline',
258+
'formElement' => 'multiline',
259+
'visible' => true,
260+
'required' => '1',
261+
'label' => __('Multiline address'),
262+
'sortOrder' => '70',
263+
'notice' => 'note',
264+
'default' => 'Default',
265+
'size' => '2',
266+
'componentType' => Field::NAME,
267+
],
268+
],
269+
],
270+
],
253271
],
254272
],
255273
]
@@ -477,6 +495,7 @@ protected function getAttributeMock($type = 'customer', $options = [])
477495
$this->injectVisibilityProps($attributeMock, $attributeBooleanMock, $options);
478496
if ($type == "address") {
479497
$mocks[] = $this->getCountryAttrMock();
498+
$mocks[] = $this->getStreetAttrMock();
480499
}
481500
return $mocks;
482501
}
@@ -544,6 +563,54 @@ function ($origName) {
544563
return $countryAttrMock;
545564
}
546565

566+
/**
567+
* @return AbstractAttribute|\PHPUnit_Framework_MockObject_MockObjec
568+
*/
569+
private function getStreetAttrMock()
570+
{
571+
$attributeMock = $this->getMockBuilder(AbstractAttribute::class)
572+
->setMethods(
573+
[
574+
'getAttributeCode',
575+
'getDataUsingMethod',
576+
'usesSource',
577+
'getFrontendInput',
578+
'getIsVisible',
579+
'getSource',
580+
'getIsUserDefined',
581+
'getUsedInForms',
582+
'getEntityType',
583+
]
584+
)
585+
->disableOriginalConstructor()
586+
->getMockForAbstractClass();
587+
588+
$map = [
589+
['frontend_input', null, 'multiline'],
590+
['is_required', null, '1'],
591+
['frontend_label', null, __('Multiline address')],
592+
['note', null, 'note'],
593+
['sort_order', null, '70'],
594+
['note', null, null],
595+
['default_value', null, 'Default'],
596+
['multiline_count', null, 2],
597+
];
598+
599+
$attributeMock->method('getDataUsingMethod')
600+
->will($this->returnValueMap($map));
601+
602+
$attributeMock->method('getAttributeCode')
603+
->willReturn('street');
604+
605+
$attributeMock->method('usesSource')
606+
->willReturn(false);
607+
608+
$attributeMock->method('getIsVisible')
609+
->willReturn(true);
610+
611+
return $attributeMock;
612+
}
613+
547614
/**
548615
* @return void
549616
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -1470,7 +1537,25 @@ private function getExpectationForVisibleAttributes()
14701537
],
14711538
],
14721539
],
1473-
]
1540+
],
1541+
'street' => [
1542+
'arguments' => [
1543+
'data' => [
1544+
'config' => [
1545+
'dataType' => 'multiline',
1546+
'formElement' => 'multiline',
1547+
'visible' => true,
1548+
'required' => '1',
1549+
'label' => __('Multiline address'),
1550+
'sortOrder' => '70',
1551+
'notice' => 'note',
1552+
'default' => 'Default',
1553+
'size' => '2',
1554+
'componentType' => Field::NAME,
1555+
],
1556+
],
1557+
],
1558+
],
14741559
],
14751560
],
14761561
];

app/code/Magento/Deploy/Package/Processor/PostProcessor/CssUrls.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,21 @@ private function parseCss(array $urlMap, $cssFilePath, $packagePath, $cssContent
124124
. str_repeat('../', count(explode('/', $cssFileBasePath)))
125125
. $this->minification->addMinifiedSign($matchedFile->getDeployedFilePath())
126126
];
127+
} else {
128+
$filePathInBase = $package->getArea() .
129+
'/' . Package::BASE_THEME .
130+
'/' . $package->getLocale() .
131+
'/' . $lookupFileId;
132+
if ($this->staticDir->isReadable($this->minification->addMinifiedSign($filePathInBase))) {
133+
$urlMap[$url][] = [
134+
'filePath' => $this->minification->addMinifiedSign($packagePath . '/' . $cssFilePath),
135+
'replace' => str_repeat('../', count(explode('/', $cssFileBasePath)) + 4)
136+
. $this->minification->addMinifiedSign($filePathInBase),
137+
];
138+
}
127139
}
128140
}
141+
129142
return $urlMap;
130143
}
131144

app/code/Magento/Payment/Helper/Data.php

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function getStoreMethods($store = null, $quote = null)
147147
}
148148
$res[] = $methodInstance;
149149
}
150-
150+
// phpcs:ignore Generic.PHP.NoSilencedErrors
151151
@uasort(
152152
$res,
153153
function (MethodInterface $a, MethodInterface $b) {
@@ -267,14 +267,12 @@ public function getPaymentMethodList($sorted = true, $asLabelValue = false, $wit
267267
$groupRelations = [];
268268

269269
foreach ($this->getPaymentMethods() as $code => $data) {
270-
if (!empty($data['active'])) {
271-
$storedTitle = $this->getMethodInstance($code)->getConfigData('title', $store);
272-
if (!empty($storedTitle)) {
273-
$methods[$code] = $storedTitle;
274-
} elseif (!empty($data['title'])) {
275-
$methods[$code] = $data['title'];
276-
}
270+
$storeId = $store ? (int)$store->getId() : null;
271+
$storedTitle = $this->getMethodStoreTitle($code, $storeId);
272+
if (!empty($storedTitle)) {
273+
$methods[$code] = $storedTitle;
277274
}
275+
278276
if ($asLabelValue && $withGroups && isset($data['group'])) {
279277
$groupRelations[$code] = $data['group'];
280278
}
@@ -356,4 +354,21 @@ public function getZeroSubTotalPaymentAutomaticInvoice($store = null)
356354
$store
357355
);
358356
}
357+
358+
/**
359+
* Get config title of payment method
360+
*
361+
* @param string $code
362+
* @param int|null $storeId
363+
* @return string
364+
*/
365+
private function getMethodStoreTitle(string $code, $storeId = null): string
366+
{
367+
$configPath = sprintf('%s/%s/title', self::XML_PATH_PAYMENT_METHODS, $code);
368+
return (string) $this->scopeConfig->getValue(
369+
$configPath,
370+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
371+
$storeId
372+
);
373+
}
359374
}

app/code/Magento/Payment/Test/Unit/Helper/DataTest.php

Lines changed: 38 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
namespace Magento\Payment\Test\Unit\Helper;
88

9-
use \Magento\Payment\Helper\Data;
10-
119
use Magento\Framework\TestFramework\Unit\Matcher\MethodInvokedAtIndex;
10+
use Magento\Payment\Helper\Data;
11+
use Magento\Store\Model\ScopeInterface;
1212

1313
class DataTest extends \PHPUnit\Framework\TestCase
1414
{
@@ -37,6 +37,9 @@ class DataTest extends \PHPUnit\Framework\TestCase
3737
*/
3838
private $appEmulation;
3939

40+
/**
41+
* @inheritDoc
42+
*/
4043
protected function setUp()
4144
{
4245
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -57,6 +60,9 @@ protected function setUp()
5760
$this->helper = $objectManagerHelper->getObject($className, $arguments);
5861
}
5962

63+
/**
64+
* @return void
65+
*/
6066
public function testGetMethodInstance()
6167
{
6268
list($code, $class, $methodInstance) = ['method_code', 'method_class', 'method_instance'];
@@ -170,6 +176,9 @@ public function testSortMethods(array $methodA, array $methodB)
170176
);
171177
}
172178

179+
/**
180+
* @return void
181+
*/
173182
public function testGetMethodFormBlock()
174183
{
175184
list($blockType, $methodCode) = ['method_block_type', 'method_code'];
@@ -195,6 +204,9 @@ public function testGetMethodFormBlock()
195204
$this->assertSame($blockMock, $this->helper->getMethodFormBlock($methodMock, $layoutMock));
196205
}
197206

207+
/**
208+
* @return void`
209+
*/
198210
public function testGetInfoBlock()
199211
{
200212
$blockType = 'method_block_type';
@@ -220,6 +232,9 @@ public function testGetInfoBlock()
220232
$this->assertSame($blockMock, $this->helper->getInfoBlock($infoMock));
221233
}
222234

235+
/**
236+
* @return void
237+
*/
223238
public function testGetInfoBlockHtml()
224239
{
225240
list($storeId, $blockHtml, $secureMode, $blockType) = [1, 'HTML MARKUP', true, 'method_block_type'];
@@ -257,6 +272,23 @@ public function testGetInfoBlockHtml()
257272
$this->assertEquals($blockHtml, $this->helper->getInfoBlockHtml($infoMock, $storeId));
258273
}
259274

275+
/**
276+
* @return array
277+
*/
278+
public function getSortMethodsDataProvider()
279+
{
280+
return [
281+
[
282+
['code' => 'methodA', 'data' => ['sort_order' => 0]],
283+
['code' => 'methodB', 'data' => ['sort_order' => 1]]
284+
],
285+
[
286+
['code' => 'methodA', 'data' => ['sort_order' => 2]],
287+
['code' => 'methodB', 'data' => ['sort_order' => 1]],
288+
]
289+
];
290+
}
291+
260292
/**
261293
* @param bool $sorted
262294
* @param bool $asLabelValue
@@ -288,17 +320,10 @@ public function testGetPaymentMethodList(
288320
]
289321
);
290322

323+
$titlePath = sprintf('%s/%s/title', Data::XML_PATH_PAYMENT_METHODS, $paymentMethod['code']);
291324
$this->scopeConfig->method('getValue')
292-
->with(sprintf('%s/%s/model', Data::XML_PATH_PAYMENT_METHODS, $paymentMethod['code']))
293-
->willReturn(\Magento\Payment\Model\Method\AbstractMethod::class);
294-
295-
$methodInstanceMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class)
296-
->getMockForAbstractClass();
297-
$methodInstanceMock->method('getConfigData')
298-
->with('title', null)
325+
->with($titlePath, ScopeInterface::SCOPE_STORE, null)
299326
->willReturn($configTitle);
300-
$this->methodFactory->method('create')
301-
->willReturn($methodInstanceMock);
302327

303328
$this->paymentConfig->method('getGroups')
304329
->willReturn($groups);
@@ -307,23 +332,6 @@ public function testGetPaymentMethodList(
307332
$this->assertEquals($expectedPaymentMethodList, $paymentMethodList);
308333
}
309334

310-
/**
311-
* @return array
312-
*/
313-
public function getSortMethodsDataProvider()
314-
{
315-
return [
316-
[
317-
['code' => 'methodA', 'data' => ['sort_order' => 0]],
318-
['code' => 'methodB', 'data' => ['sort_order' => 1]]
319-
],
320-
[
321-
['code' => 'methodA', 'data' => ['sort_order' => 2]],
322-
['code' => 'methodB', 'data' => ['sort_order' => 1]],
323-
]
324-
];
325-
}
326-
327335
/**
328336
* @return array
329337
*/
@@ -345,27 +353,12 @@ public function paymentMethodListDataProvider(): array
345353
],
346354
['payment_method' => 'Config Payment Title'],
347355
],
348-
'Payment method with default title' =>
349-
[
350-
true,
351-
false,
352-
false,
353-
null,
354-
[
355-
'code' => 'payment_method',
356-
'data' => [
357-
'active' => 1,
358-
'title' => 'Payment Title',
359-
],
360-
],
361-
['payment_method' => 'Payment Title'],
362-
],
363356
'Payment method as value => label' =>
364357
[
365358
true,
366359
true,
367360
false,
368-
null,
361+
'Payment Title',
369362
[
370363
'code' => 'payment_method',
371364
'data' => [
@@ -385,7 +378,7 @@ public function paymentMethodListDataProvider(): array
385378
true,
386379
true,
387380
true,
388-
null,
381+
'Payment Title',
389382
[
390383
'code' => 'payment_method',
391384
'data' => [

0 commit comments

Comments
 (0)