Skip to content

Commit 6e6ead7

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-93306-minify_exclude' into 2.3-regression-pr-HB
2 parents 971568e + 169cab9 commit 6e6ead7

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

lib/internal/Magento/Framework/View/Asset/Minification.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,16 @@ public function getExcludes($contentType)
162162
private function getMinificationExcludeValues($key)
163163
{
164164
$configValues = $this->scopeConfig->getValue($key, $this->scope) ?? [];
165-
165+
//value used to be a string separated by 'newline' separator so we need to convert it to array
166+
if (!is_array($configValues)) {
167+
$configValuesFromString = [];
168+
foreach (explode("\n", $configValues) as $exclude) {
169+
if (trim($exclude) != '') {
170+
$configValuesFromString[] = trim($exclude);
171+
}
172+
}
173+
$configValues = $configValuesFromString;
174+
}
166175
return array_values($configValues);
167176
}
168177
}

lib/internal/Magento/Framework/View/Test/Unit/Asset/MinificationTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ public function isMinifiedFilenameDataProvider()
195195
}
196196

197197
/**
198+
* Test dev/js/minify_exclude system value as array
199+
*
198200
* @return void
199201
*/
200202
public function testGetExcludes()
@@ -213,4 +215,39 @@ public function testGetExcludes()
213215
/** check cache: */
214216
$this->assertEquals($expected, $this->minification->getExcludes('js'));
215217
}
218+
219+
/**
220+
* Test dev/js/minify_exclude system value backward compatibility when value was a string
221+
*
222+
* @param string $value
223+
* @param array $expectedValue
224+
* @return void
225+
*
226+
* @dataProvider getExcludesTinyMceAsStringDataProvider
227+
*/
228+
public function testGetExcludesTinyMceAsString(string $value, array $expectedValue)
229+
{
230+
$this->scopeConfigMock
231+
->expects($this->once())
232+
->method('getValue')
233+
->with('dev/js/minify_exclude')
234+
->willReturn($value);
235+
236+
$this->assertEquals($expectedValue, $this->minification->getExcludes('js'));
237+
/** check cache: */
238+
$this->assertEquals($expectedValue, $this->minification->getExcludes('js'));
239+
}
240+
241+
242+
/**
243+
* @return array
244+
*/
245+
public function getExcludesTinyMceAsStringDataProvider()
246+
{
247+
return [
248+
["/tiny_mce/ \n /tiny_mce2/", ['/tiny_mce/', '/tiny_mce2/']],
249+
['/tiny_mce/', ['/tiny_mce/']],
250+
[' /tiny_mce/', ['/tiny_mce/']],
251+
];
252+
}
216253
}

0 commit comments

Comments
 (0)