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