Skip to content

Commit 1ac88c3

Browse files
committed
Update template minifier tests
1 parent 59be884 commit 1ac88c3

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public function testMinify(): void
173173
<?php echo '//some.link.com/' ?>
174174
<em>inline text</em>
175175
<a href="http://www.<?php echo 'hi' ?>"></a>
176-
<?php// if (\$block->getSomeVariable() > 1):?>
176+
<?php // if (\$block->getSomeVariable() > 1):?>
177177
<?php echo \$block->getChildHtml('someChildBlock'); ?>
178178
<?php //else:?>
179179
<?php // echo \$block->getChildHtml('anotherChildBlock'); ?>
@@ -190,6 +190,12 @@ public function testMinify(): void
190190
// This is not a comment and should be preserved.
191191
// This is not a comment <?= 'either.' ?>
192192
</div>
193+
<textarea>
194+
Spaces in textareas
195+
are significant and
196+
should not be removed.
197+
</textarea>
198+
This is HTML : <?php//
193199
<?php
194200
\$someothertext = <<<SOMEOTHERTEXT
195201
mytext
@@ -202,7 +208,7 @@ public function testMinify(): void
202208
TEXT;
203209

204210
$expectedContent = <<<TEXT
205-
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ ?> <?php ?> <html><head><title>Test title</title></head><link rel="stylesheet" href='https://www.example.com/2' type="text/css" /><link rel="stylesheet" type="text/css" media="all" href="https://www.example.com/1" type="text/css" /><body><a href="http://somelink.com/text.html">Text Link</a> <img src="test.png" alt="some text" /><?php echo \$block->someMethod(); ?> <img src="data:image/gif;base64,P///yH5BAEAAAA" data-component="main-image"><?= \$block->someMethod(); ?> <div style="width: 800px" class="<?php echo \$block->getClass() ?>" /><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-component="main-image"><script>
211+
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ /** multi line comment containing a <span> */ echo 'test';?> <html><head><title>Test title</title></head><link rel="stylesheet" href='https://www.example.com/2' type="text/css" /><link rel="stylesheet" type="text/css" media="all" href="https://www.example.com/1" type="text/css" /><body><a href="http://somelink.com/text.html">Text Link</a> <img src="test.png" alt="some text" /><?= \$block->someMethod() ?> <img src="data:image/gif;base64,P///yH5BAEAAAA" data-component="main-image"><?= \$block->someMethod() ?> <div style="width: 800px" class="<?= \$block->getClass() ?>" /><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-component="main-image"><script>
206212
var i = 1;
207213
var j = 1;
208214
@@ -215,15 +221,26 @@ public function testMinify(): void
215221
return {
216222
'someProperty': test,
217223
'someMethod': function () {
218-
alert(<?php echo \$block->getJsAlert() ?>);
224+
alert(<?= \$block->getJsAlert() ?>);
219225
}
220226
}
221227
});
222228
//]]>
223-
</script><?php echo "http://some.link.com/" ?> <?php echo "//some.link.com/" ?> <?php echo '//some.link.com/' ?> <em>inline text</em> <a href="http://www.<?php echo 'hi' ?>"></a> <?php ?> <?php echo \$block->getChildHtml('someChildBlock'); ?> <?php ?> <?php ?> <?php ?></body><?php \$sometext = <<<SOMETEXT
229+
</script><?= "http://some.link.com/" ?> <?= "//some.link.com/" ?> <?= '//some.link.com/' ?> <em>inline text</em> <a href="http://www.<?= 'hi' ?>"></a> <?php ?> <?= \$block->getChildHtml('someChildBlock') ?> <?php ?> <?php ?> <?php ?></body><?php \$sometext = <<<SOMETEXT
224230
mytext
225231
mytextline2
226-
SOMETEXT; ?></html>
232+
<span> </span>
233+
SOMETEXT
234+
;?> <div> // This is not a comment and should be preserved. // This is not a comment <?= 'either.' ?></div><textarea>
235+
Spaces in textareas
236+
are significant and
237+
should not be removed.
238+
</textarea> This is HTML : <?php// <?php \$someothertext = <<<SOMEOTHERTEXT
239+
mytext
240+
{\$block->getChildHtml('someChildBlock')}
241+
<span> </span>
242+
SOMEOTHERTEXT
243+
;?></html>
227244
TEXT;
228245

229246
$this->appDirectoryMock->expects($this->once())

0 commit comments

Comments
 (0)