Remove double %
[htmlpurifier.git] / tests / HTMLPurifier / AttrDef / CSS / ColorTest.php
blob74a6692ecdecd8dbf3bb775ca7425b5a54d3f3f6
1 <?php
3 class HTMLPurifier_AttrDef_CSS_ColorTest extends HTMLPurifier_AttrDefHarness
6 public function test()
8 $this->def = new HTMLPurifier_AttrDef_CSS_Color();
10 $this->assertDef('#F00');
11 $this->assertDef('#fff');
12 $this->assertDef('#eeeeee');
13 $this->assertDef('#808080');
15 $this->assertDef('rgb(255, 0, 0)', 'rgb(255,0,0)'); // rm spaces
16 $this->assertDef('rgb(100%,0%,0%)');
17 $this->assertDef('rgb(50.5%,23.2%,43.9%)'); // decimals okay
18 $this->assertDef('rgb(-5,0,0)', 'rgb(0,0,0)'); // negative values
19 $this->assertDef('rgb(295,0,0)', 'rgb(255,0,0)'); // max values
20 $this->assertDef('rgb(12%,150%,0%)', 'rgb(12%,100%,0%)'); // percentage max values
22 $this->assertDef('rgba(255, 0, 0, 0)', 'rgba(255,0,0,0)'); // rm spaces
23 $this->assertDef('rgba(100%,0%,0%,.4)');
24 $this->assertDef('rgba(38.1%,59.7%,1.8%,0.7)', 'rgba(38.1%,59.7%,1.8%,.7)'); // decimals okay
26 $this->assertDef('hsl(275, 45%, 81%)', 'hsl(275,45%,81%)'); // rm spaces
27 $this->assertDef('hsl(100,0%,0%)');
28 $this->assertDef('hsl(38,59.7%,1.8%)', 'hsl(38,59.7%,1.8%)'); // decimals okay
29 $this->assertDef('hsl(-11,-15%,25%)', 'hsl(0,0%,25%)'); // negative values
30 $this->assertDef('hsl(380,125%,0%)', 'hsl(360,100%,0%)'); // max values
32 $this->assertDef('hsla(100, 74%, 29%, 0)', 'hsla(100,74%,29%,0)'); // rm spaces
33 $this->assertDef('hsla(154,87%,21%,.4)');
34 $this->assertDef('hsla(45,94.3%,4.1%,0.7)', 'hsla(45,94.3%,4.1%,.7)'); // decimals okay
36 $this->assertDef('#G00', false);
37 $this->assertDef('cmyk(40, 23, 43, 23)', false);
38 $this->assertDef('rgb(0%, 23, 68%)', false); // no mixed type
39 $this->assertDef('rgb(231, 144, 28.2%)', false); // no mixed type
40 $this->assertDef('hsl(18%,12%,89%)', false); // integer, percentage, percentage
42 // clip numbers outside sRGB gamut
43 $this->assertDef('rgb(200%, -10%, 0%)', 'rgb(100%,0%,0%)');
44 $this->assertDef('rgb(256,-23,34)', 'rgb(255,0,34)');
46 // color keywords, of course
47 $this->assertDef('red', '#FF0000');
49 // malformed hex declaration
50 $this->assertDef('808080', '#808080');
51 $this->assertDef('000000', '#000000');
52 $this->assertDef('fed', '#fed');
54 // maybe hex transformations would be another nice feature
55 // at the very least transform rgb percent to rgb integer
61 // vim: et sw=4 sts=4