ClassTest.php 1.5 KB

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