Fix newline issues in tests.
[htmlpurifier/darkodev.git] / tests / HTMLPurifier / DoctypeRegistryTest.php
blobac68b9273506740ea4dab57b13396a4addbe25ad
1 <?php
3 class HTMLPurifier_DoctypeRegistryTest extends HTMLPurifier_Harness
6 function test_register() {
8 $registry = new HTMLPurifier_DoctypeRegistry();
10 $d = $registry->register(
11 $name = 'XHTML 1.0 Transitional',
12 $xml = true,
13 $modules = array('module-one', 'module-two'),
14 $tidyModules = array('lenient-module'),
15 $aliases = array('X10T')
18 $d2 = new HTMLPurifier_Doctype($name, $xml, $modules, $tidyModules, $aliases);
20 $this->assertIdentical($d, $d2);
21 $this->assertSame($d, $registry->get('XHTML 1.0 Transitional'));
23 // test shorthand
24 $d = $registry->register(
25 $name = 'XHTML 1.0 Strict', true, 'module', 'Tidy', 'X10S'
27 $d2 = new HTMLPurifier_Doctype($name, true, array('module'), array('Tidy'), array('X10S'));
29 $this->assertIdentical($d, $d2);
33 function test_get() {
35 // see also alias and register tests
37 $registry = new HTMLPurifier_DoctypeRegistry();
39 $this->expectError('Doctype XHTML 2.0 does not exist');
40 $registry->get('XHTML 2.0');
42 // prevent XSS
43 $this->expectError('Doctype &lt;foo&gt; does not exist');
44 $registry->get('<foo>');
48 function testAliases() {
50 $registry = new HTMLPurifier_DoctypeRegistry();
52 $d1 = $registry->register('Doc1', true, array(), array(), array('1'));
54 $this->assertSame($d1, $registry->get('Doc1'));
55 $this->assertSame($d1, $registry->get('1'));
57 $d2 = $registry->register('Doc2', true, array(), array(), array('2'));
59 $this->assertSame($d2, $registry->get('Doc2'));
60 $this->assertSame($d2, $registry->get('2'));
62 $d3 = $registry->register('1', true, array(), array(), array());
64 // literal name overrides alias
65 $this->assertSame($d3, $registry->get('1'));
67 $d4 = $registry->register('One', true, array(), array(), array('1'));
69 $this->assertSame($d4, $registry->get('One'));
70 // still it overrides
71 $this->assertSame($d3, $registry->get('1'));