[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 require_once DOKU_INC.'lib/exe/css.php'; 4 5 class 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('#comment/* */{color:lime;}', css_compress($text)); 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('#foo{color:lime;}', css_compress($text)); 33 } 34 35 function test_slcom3(){ 36 $text = '#foo { 37 background-image: url(http://foo.bar/baz.jpg); // this is a comment 38 }'; 39 $this->assertEquals('#foo{background-image:url(http://foo.bar/baz.jpg);}', css_compress($text)); 40 } 41 42 function test_slcom4(){ 43 $text = '#foo { 44 background-image: url(http://foo.bar/baz.jpg); background-image: url(http://foo.bar/baz.jpg); // this is a comment 45 }'; 46 $this->assertEquals('#foo{background-image:url(http://foo.bar/baz.jpg);background-image:url(http://foo.bar/baz.jpg);}', css_compress($text)); 47 } 48 49 function test_slcom5(){ 50 $text = '#foo { 51 background-image: url(http://foo.bar/baz.jpg); // background-image: url(http://foo.bar/baz.jpg); this is all commented 52 }'; 53 $this->assertEquals('#foo{background-image:url(http://foo.bar/baz.jpg);}', css_compress($text)); 54 } 55 56 function test_slcom6(){ 57 $text = '#foo { 58 background-image: url(//foo.bar/baz.jpg); // background-image: url(http://foo.bar/baz.jpg); this is all commented 59 }'; 60 $this->assertEquals('#foo{background-image:url(//foo.bar/baz.jpg);}', css_compress($text)); 61 } 62 63 function test_slcom7(){ 64 $text = '#foo a[href ^="https://"], #foo a[href ^=\'https://\'] { 65 background-image: url(//foo.bar/baz.jpg); // background-image: url(http://foo.bar/baz.jpg); this is \'all\' "commented" 66 }'; 67 $this->assertEquals('#foo a[href ^="https://"],#foo a[href ^=\'https://\']{background-image:url(//foo.bar/baz.jpg);}', css_compress($text)); 68 } 69 70 71 function test_hack(){ 72 $text = '/* Mac IE will not see this and continue with inline-block */ 73 /* \\*/ 74 display: inline; 75 /* */'; 76 $this->assertEquals('/* \\*/display:inline;/* */', css_compress($text)); 77 } 78 79 function test_hack2(){ 80 $text = '/* min-height hack for Internet Explorer http://www.cssplay.co.uk/boxes/minheight.html */ 81 /*\\*/ 82 * html .page { 83 height: 450px; 84 } 85 /**/'; 86 $this->assertEquals('/*\\*/* html .page{height:450px;}/**/', css_compress($text)); 87 } 88 89 function test_nl1(){ 90 $text = "a{left:20px;\ntop:20px}"; 91 $this->assertEquals('a{left:20px;top:20px}', css_compress($text)); 92 } 93 94 function test_shortening() { 95 $input = array( 96 'margin:0em 0em 0em 0em ul.test margin:0em :0em div#FFFFFF {', 97 'margin: 1px 1px 1px 1px;', 98 'padding: 1px 2px 1px 2px;', 99 'margin: 1px 2px 3px 1px;', 100 'padding: 1px 2px 3px 4px;', 101 'margin: 00.00em 0em 01.00px 0em;', 102 'padding: 0010em 0010.00em 00.00em 00.00100em;', 103 'padding: 0010% 0010.00% 00.00% 00.00100xxx;', 104 'padding: 0.0em .0em 0.em 00.00em;', 105 'padding: 01.0em;', 106 'color: #FFFFFF;', 107 'color: #777777;', 108 'color: #123456;', 109 'border: 01.0em solid #ffffff;', 110 ); 111 112 $expected = array( 113 'margin:0em 0em 0em 0em ul.test margin:0em :0em div#FFFFFF{', 114 'margin:1px;', 115 'padding:1px 2px;', 116 'margin:1px 2px 3px 1px;', 117 'padding:1px 2px 3px 4px;', 118 'margin:0 0 1px 0;', 119 'padding:10em 10em 0 .001em;', 120 'padding:10% 10% 0 00.00100xxx;', 121 'padding:0;', 122 'padding:1em;', 123 'color:#FFF;', 124 'color:#777;', 125 'color:#123456;', 126 'border:1em solid #fff;', 127 ); 128 129 $input = array_map('css_compress', $input); 130 131 $this->assertEquals($expected, $input); 132 } 133 134 function test_data() { 135 $input = 'list-style-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7);'; 136 $expect = 'list-style-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7);'; 137 138 $this->assertEquals($expect, css_compress($input)); 139 } 140 141 function test_quotes() { 142 $input = '/* "blockcomment" */ content: "/* STR2 : STR1 */ thisis : inquote"; STR1: 10px; STR2:"STR1"; STR3:\'STR1\';'; 143 $expect = 'content:"/* STR2 : STR1 */ thisis : inquote";STR1:10px;STR2:"STR1";STR3:\'STR1\';'; 144 145 $this->assertEquals($expect, css_compress($input)); 146 } 147 148 function test_escapedQuotes() { 149 $inputEscapedQuote = 'content:"one quote visible: \\" "; foo: bar;//"'; 150 $expectedOutput = 'content:"one quote visible: \\" ";foo:bar;'; 151 152 $this->assertEquals($expectedOutput, css_compress($inputEscapedQuote)); 153 } 154 } 155 156 //Setup VIM: ex: et ts=4 :
title
Description
Body
title
Description
Body
title
Description
Body
title
Body