3 class HTMLPurifierTest
extends HTMLPurifier_Harness
7 public function testNull()
9 $this->assertPurification("Null byte\0", "Null byte");
12 public function test_purifyArray()
14 $this->assertIdentical(
15 $this->purifier
->purifyArray(
16 array('Good', '<b>Sketchy', 'foo' => '<script>bad</script>')
18 array('Good', '<b>Sketchy</b>', 'foo' => '')
21 $this->assertIsA($this->purifier
->context
, 'array');
25 public function testGetInstance()
27 $purifier = HTMLPurifier
::getInstance();
28 $purifier2 = HTMLPurifier
::getInstance();
29 $this->assertReference($purifier, $purifier2);
32 public function testMakeAbsolute()
34 $this->config
->set('URI.Base', 'http://example.com/bar/baz.php');
35 $this->config
->set('URI.MakeAbsolute', true);
36 $this->assertPurification(
37 '<a href="foo.txt">Foobar</a>',
38 '<a href="http://example.com/bar/foo.txt">Foobar</a>'
42 public function testDisableResources()
44 $this->config
->set('URI.DisableResources', true);
45 $this->assertPurification('<img src="foo.jpg" />', '');
48 public function test_addFilter_deprecated()
50 $this->expectError('HTMLPurifier->addFilter() is deprecated, use configuration directives in the Filter namespace or Filter.Custom');
51 generate_mock_once('HTMLPurifier_Filter');
52 $this->purifier
->addFilter($mock = new HTMLPurifier_FilterMock());
53 $mock->expectOnce('preFilter');
54 $mock->expectOnce('postFilter');
55 $this->purifier
->purify('foo');