Skip to content

Commit 6c40339

Browse files
committed
Merge branch 'ACP2E-3925' of https://github.com/adobe-commerce-tier-4/magento2ce into Tier4-08-13-2025
2 parents a6d0c39 + 6e91047 commit 6c40339

File tree

2 files changed

+51
-13
lines changed

2 files changed

+51
-13
lines changed

composer.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2013 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Framework\Code\Test\Unit\Minifier\Adapter\Js;
77

@@ -10,12 +10,50 @@
1010

1111
class JShrinkTest extends TestCase
1212
{
13-
public function testMinify()
13+
/**
14+
* @param string $content
15+
* @param string $expected
16+
* @return void
17+
* @throws \Exception
18+
* @dataProvider minifyDataProvider
19+
*/
20+
public function testMinify(string $content, string $expected): void
1421
{
15-
$content = file_get_contents(__DIR__ . '/../../_files/js/original.js');
1622
$minifier = new JShrink();
1723
$actual = $minifier->minify($content);
18-
$expected = "var one='one';var two='two';";
1924
$this->assertEquals($expected, $actual);
2025
}
26+
27+
public static function minifyDataProvider(): array
28+
{
29+
return [
30+
'line breaks' => [
31+
'content' => file_get_contents(__DIR__ . '/../../_files/js/original.js'),
32+
'expected' => "var one='one';var two='two';"
33+
],
34+
'regex1' => [
35+
'content' => <<<JS
36+
function test (string) {
37+
return (string || '').replace(
38+
/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,
39+
'\\$1'
40+
)
41+
}
42+
JS,
43+
'expected' => <<<JS
44+
function test(string){return(string||'').replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,'\\$1')}
45+
JS
46+
],
47+
'regex2' => [
48+
'content' => <<<JS
49+
function test(str) {
50+
return (/^[a-zA-Z\d\-_/:.[\]&@()! ]+$/i).test(str);
51+
}
52+
JS,
53+
'expected' => <<<JS
54+
function test(str){return(/^[a-zA-Z\d\-_/:.[\]&@()! ]+$/i).test(str);}
55+
JS
56+
],
57+
];
58+
}
2159
}

0 commit comments

Comments
 (0)