1+ <?php
2+
3+
4+ namespace Nckg \Minify \Test ;
5+
6+
7+ use Nckg \Minify \Minifier ;
8+
9+ class MinifierTest extends TestCase
10+ {
11+ /** @test */
12+ public function it_shortens_multiple_white_spaces ()
13+ {
14+ $ string = '<a href="/foo" class="bar moo ">Hello World</a> ' ;
15+ $ expected = '<a href="/foo" class="bar moo ">Hello World</a> ' ;
16+ $ this ->assertMinifiedString ($ expected , $ string );
17+ }
18+
19+ /** @test */
20+ public function it_removes_comments_except_ie_conditions ()
21+ {
22+ $ string = [
23+ '<!-- Hello World --> ' ,
24+ '<!--[if lt IE 9]> ' ,
25+ 'Hello IE ' ,
26+ '<![endif]--> ' ,
27+ ];
28+ $ expected = '<!--[if lt IE 9]>Hello IE<![endif]--> ' ;
29+ $ this ->assertMinifiedString ($ expected , implode ('' , $ string ));
30+ }
31+
32+ /** @test */
33+ public function it_collapses_new_lines ()
34+ {
35+ $ string = 'Hello
36+ World ' ;
37+ $ expected = 'Hello World ' ;
38+ $ this ->assertMinifiedString ($ expected , $ string );
39+ }
40+
41+ /** @test */
42+ public function it_removes_comments ()
43+ {
44+ $ string = '// Hello World
45+ Batman ' ;
46+ $ expected = ' Batman ' ;
47+ $ this ->assertMinifiedString ($ expected , $ string );
48+ }
49+
50+ /** @test */
51+ public function it_minifies_an_entire_page_correct ()
52+ {
53+ $ string = file_get_contents (__DIR__ . '/_data/page.html ' );
54+ $ expected = file_get_contents (__DIR__ . '/_data/page-minified.html ' );
55+ $ this ->assertMinifiedString ($ expected , $ string );
56+ }
57+
58+ /**
59+ * @param $expected
60+ * @param $string
61+ */
62+ protected function assertMinifiedString ($ expected , $ string )
63+ {
64+ $ minifier = new Minifier ();
65+ $ this ->assertSame ($ expected , $ minifier ->html ($ string ));
66+ }
67+ }
0 commit comments