xref: /dokuwiki/_test/tests/lib/exe/css_css_compress.test.php (revision ed6bf75f5a78a346e3c3192b2bab79450e206598)
1<?php
2
3require_once DOKU_INC.'lib/exe/css.php';
4
5class css_css_compress_test extends DokuWikiTest {
6
7    function test_mlcom1(){
8        $text = '/**
9                  * A multi
10                  * line *test*
11                  * check
12                  */';
13        $this->assertEquals(css_compress($text), '');
14    }
15
16    function test_mlcom2(){
17        $text = '#comment/* */ {
18                    color: lime;
19                }';
20        $this->assertEquals(css_compress($text), '#comment/* */{color:lime;}');
21    }
22
23    function test_slcom1(){
24        $text = '// this is a comment';
25        $this->assertEquals(css_compress($text), '');
26    }
27
28    function test_slcom2(){
29        $text = '#foo {
30                    color: lime; // another comment
31                }';
32        $this->assertEquals(css_compress($text), '#foo{color:lime;}');
33    }
34
35    function test_slcom3(){
36        $text = '#foo {
37                    background-image: url(http://foo.bar/baz.jpg);
38                }';
39        $this->assertEquals(css_compress($text), '#foo{background-image:url(http://foo.bar/baz.jpg);}');
40    }
41
42    function test_hack(){
43        $text = '/* Mac IE will not see this and continue with inline-block */
44                 /* \\*/
45                 display: inline;
46                 /* */';
47        $this->assertEquals(css_compress($text), '/* \\*/display:inline;/* */');
48    }
49
50    function test_hack2(){
51        $text = '/* min-height hack for Internet Explorer http://www.cssplay.co.uk/boxes/minheight.html */
52                 /*\\*/
53                 * html .page {
54                     height: 450px;
55                 }
56                 /**/';
57        $this->assertEquals(css_compress($text), '/*\\*/* html .page{height:450px;}/**/');
58    }
59
60    function test_nl1(){
61        $text = "a{left:20px;\ntop:20px}";
62        $this->assertEquals(css_compress($text), 'a{left:20px;top:20px}');
63    }
64
65    function test_shortening() {
66        $input = array(
67            'margin:0em 0em 0em 0em ul.test margin:0em :0em div#FFFFFF {',
68            'margin:  1px 1px 1px 1px;',
69            'padding: 1px 2px 1px 2px;',
70            'margin:  1px 2px 3px 1px;',
71            'padding: 1px 2px 3px 4px;',
72            'margin:  00.00em 0em 01.00px 0em;',
73            'padding: 0010em 0010.00em 00.00em 00.00100em;',
74            'padding: 0010% 0010.00% 00.00% 00.00100xxx;',
75            'padding: 0.0em .0em 0.em 00.00em;',
76            'padding: 01.0em;',
77            'color:   #FFFFFF;',
78            'color:   #777777;',
79            'color:   #123456;',
80            'border:  01.0em solid #ffffff;',
81        );
82
83        $expected = array(
84            'margin:0em 0em 0em 0em ul.test margin:0em :0em div#FFFFFF{',
85            'margin:1px;',
86            'padding:1px 2px;',
87            'margin:1px 2px 3px 1px;',
88            'padding:1px 2px 3px 4px;',
89            'margin:0 0 1px 0;',
90            'padding:10em 10em 0 .001em;',
91            'padding:10% 10% 0 00.00100xxx;',
92            'padding:0;',
93            'padding:1em;',
94            'color:#FFF;',
95            'color:#777;',
96            'color:#123456;',
97            'border:1em solid #fff;',
98        );
99
100        $input = array_map('css_compress', $input);
101
102        $this->assertEquals($expected, $input);
103    }
104
105}
106
107//Setup VIM: ex: et ts=4 :
108