Implement CSS.AllowedFonts.
[htmlpurifier.git] / tests / HTMLPurifier / AttrDef / CSS / FontFamilyTest.php
blob2060076ba23a4560a13b5a20d30da32aa6a3a781
1 <?php
3 class HTMLPurifier_AttrDef_CSS_FontFamilyTest extends HTMLPurifier_AttrDefHarness
6 function test() {
8 $this->def = new HTMLPurifier_AttrDef_CSS_FontFamily();
10 $this->assertDef('Gill, Helvetica, sans-serif');
11 $this->assertDef('"Times New Roman", serif');
12 $this->assertDef('\'Times New Roman\'', '"Times New Roman"');
13 $this->assertDef('01234');
14 $this->assertDef(',', false);
15 $this->assertDef('Times New Roman, serif', '"Times New Roman", serif');
16 $this->assertDef($d = '"John\'s Font"');
17 $this->assertDef("John's Font", $d);
18 $this->assertDef($d = "\"\xE5\xAE\x8B\xE4\xBD\x93\"");
19 $this->assertDef("\xE5\xAE\x8B\xE4\xBD\x93", $d);
20 $this->assertDef("'\\','f'", "\"\\5C \", f");
21 $this->assertDef("'\\01'", "\"\"");
22 $this->assertDef("'\\20'", "\" \"");
23 $this->assertDef("\\0020", "\" \"");
24 $this->assertDef("'\\000045'", "E");
25 $this->assertDef("','", false);
26 $this->assertDef("',' foobar','", "\" foobar\"");
27 $this->assertDef("'\\27'", "\"'\"");
28 $this->assertDef('"\\22"', "\"\\22 \"");
29 $this->assertDef('"\\""', "\"\\22 \"");
30 $this->assertDef('"\'"', "\"'\"");
31 $this->assertDef("'\\000045a'", "Ea");
32 $this->assertDef("'\\00045 a'", "Ea");
33 $this->assertDef("'\\00045 a'", "\"E a\"");
34 $this->assertDef("'\\\nf'", "f");
37 function testAllowed() {
38 $this->config->set('CSS.AllowedFonts', array('serif', 'Times New Roman'));
40 $this->assertDef('serif');
41 $this->assertDef('sans-serif', false);
42 $this->assertDef('serif, sans-serif', 'serif');
43 $this->assertDef('Times New Roman', '"Times New Roman"');
44 $this->assertDef('"Times New Roman"');
45 $this->assertDef('foo', false);
50 // vim: et sw=4 sts=4