[1.4.0] Added convenient single test selector form on test runner
[htmlpurifier.git] / tests / HTMLPurifier / AttrDef / ColorTest.php
blobb44082c0d4b054573cb14eb40a2a861bc92e4074
1 <?php
3 require_once 'HTMLPurifier/AttrDef/Color.php';
4 require_once 'HTMLPurifier/AttrDefHarness.php';
6 class HTMLPurifier_AttrDef_ColorTest extends HTMLPurifier_AttrDefHarness
9 function test() {
11 $this->def = new HTMLPurifier_AttrDef_Color();
13 $this->assertDef('#F00');
14 $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
19 $this->assertDef('#G00', false);
20 $this->assertDef('cmyk(40, 23, 43, 23)', false);
21 $this->assertDef('rgb(0%, 23, 68%)', false);
23 // clip numbers outside sRGB gamut
24 $this->assertDef('rgb(200%, -10%, 0%)', 'rgb(100%,0%,0%)');
25 $this->assertDef('rgb(256,-23,34)', 'rgb(255,0,34)');
27 // color keywords, of course
28 $this->assertDef('red', '#F00');
30 // maybe hex transformations would be another nice feature
31 // at the very least transform rgb percent to rgb integer