Skip to content

Commit 8c5db47

Browse files
committed
MAGETWO-84387: CSV FILE is created incorrectly for Archive-Orders and System-Data Collector
1 parent 5dfe914 commit 8c5db47

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

app/code/Magento/Ui/Model/Export/MetadataProvider.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ public function getHeaders(UiComponentInterface $component)
118118
foreach ($this->getColumns($component) as $column) {
119119
$row[] = $column->getData('config/label');
120120
}
121+
122+
array_walk($row, function (&$header) {
123+
if (mb_strpos($header, 'ID') === 0) {
124+
$header = '"'. $header .'"';
125+
}
126+
});
127+
121128
return $row;
122129
}
123130

app/code/Magento/Ui/Test/Unit/Model/Export/MetadataProviderTest.php

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,37 @@ protected function setUp()
4040
);
4141
}
4242

43-
public function testGetHeaders()
43+
/**
44+
* @param array $columnLabels
45+
* @param array $expected
46+
* @return void
47+
* @dataProvider getColumnsDataProvider
48+
*/
49+
public function testGetHeaders(array $columnLabels, array $expected)
4450
{
4551
$componentName = 'component_name';
4652
$columnName = 'column_name';
47-
$columnLabel = 'column_label';
48-
49-
$component = $this->prepareColumns($componentName, $columnName, $columnLabel);
5053

54+
$component = $this->prepareColumns($componentName, $columnName, $columnLabels[0]);
5155
$result = $this->model->getHeaders($component);
5256
$this->assertTrue(is_array($result));
5357
$this->assertCount(1, $result);
54-
$this->assertEquals($columnLabel, $result[0]);
58+
$this->assertEquals($expected, $result);
59+
}
60+
61+
/**
62+
* @return array
63+
*/
64+
public function getColumnsDataProvider(): array
65+
{
66+
return [
67+
[['ID'],['"ID"']],
68+
[['Name'],['Name']],
69+
[['Id'],['Id']],
70+
[['id'],['id']],
71+
[['IDTEST'],['"IDTEST"']],
72+
[['ID TEST'],['"ID TEST"']],
73+
];
5574
}
5675

5776
public function testGetFields()

0 commit comments

Comments
 (0)