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.

54 lines
1.5KB

  1. <?php
  2. class HTMLPurifier_AttrDef_HTML_ClassTest extends HTMLPurifier_AttrDef_HTML_NmtokensTest
  3. {
  4. public function setUp()
  5. {
  6. parent::setUp();
  7. $this->def = new HTMLPurifier_AttrDef_HTML_Class();
  8. }
  9. public function testAllowedClasses()
  10. {
  11. $this->config->set('Attr.AllowedClasses', array('foo'));
  12. $this->assertDef('foo');
  13. $this->assertDef('bar', false);
  14. $this->assertDef('foo bar', 'foo');
  15. }
  16. public function testForbiddenClasses()
  17. {
  18. $this->config->set('Attr.ForbiddenClasses', array('bar'));
  19. $this->assertDef('foo');
  20. $this->assertDef('bar', false);
  21. $this->assertDef('foo bar', 'foo');
  22. }
  23. public function testDefault()
  24. {
  25. $this->assertDef('valid');
  26. $this->assertDef('a0-_');
  27. $this->assertDef('-valid');
  28. $this->assertDef('_valid');
  29. $this->assertDef('double valid');
  30. $this->assertDef('0stillvalid');
  31. $this->assertDef('-0');
  32. // test conditional replacement
  33. $this->assertDef('validassoc 0valid', 'validassoc 0valid');
  34. // test whitespace leniency
  35. $this->assertDef(" double\nvalid\r", 'double valid');
  36. // test case sensitivity
  37. $this->assertDef('VALID');
  38. // test duplicate removal
  39. $this->assertDef('valid valid', 'valid');
  40. }
  41. public function testXHTML11Behavior()
  42. {
  43. $this->config->set('HTML.Doctype', 'XHTML 1.1');
  44. $this->assertDef('0invalid', false);
  45. $this->assertDef('valid valid', 'valid');
  46. }
  47. }