You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.7KB

  1. <?php
  2. class HTMLPurifierTest extends HTMLPurifier_Harness
  3. {
  4. protected $purifier;
  5. public function testNull()
  6. {
  7. $this->assertPurification("Null byte\0", "Null byte");
  8. }
  9. public function test_purifyArray()
  10. {
  11. $this->assertIdentical(
  12. $this->purifier->purifyArray(
  13. array('Good', '<b>Sketchy', 'foo' => '<script>bad</script>')
  14. ),
  15. array('Good', '<b>Sketchy</b>', 'foo' => '')
  16. );
  17. $this->assertIsA($this->purifier->context, 'array');
  18. }
  19. public function testGetInstance()
  20. {
  21. $purifier = HTMLPurifier::getInstance();
  22. $purifier2 = HTMLPurifier::getInstance();
  23. $this->assertReference($purifier, $purifier2);
  24. }
  25. public function testMakeAbsolute()
  26. {
  27. $this->config->set('URI.Base', 'http://example.com/bar/baz.php');
  28. $this->config->set('URI.MakeAbsolute', true);
  29. $this->assertPurification(
  30. '<a href="foo.txt">Foobar</a>',
  31. '<a href="http://example.com/bar/foo.txt">Foobar</a>'
  32. );
  33. }
  34. public function testDisableResources()
  35. {
  36. $this->config->set('URI.DisableResources', true);
  37. $this->assertPurification('<img src="foo.jpg" />', '');
  38. }
  39. public function test_addFilter_deprecated()
  40. {
  41. $this->expectError('HTMLPurifier->addFilter() is deprecated, use configuration directives in the Filter namespace or Filter.Custom');
  42. generate_mock_once('HTMLPurifier_Filter');
  43. $this->purifier->addFilter($mock = new HTMLPurifier_FilterMock());
  44. $mock->expectOnce('preFilter');
  45. $mock->expectOnce('postFilter');
  46. $this->purifier->purify('foo');
  47. }
  48. }
  49. // vim: et sw=4 sts=4