LengthTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. class HTMLPurifier_AttrDef_CSS_LengthTest extends HTMLPurifier_AttrDefHarness
  3. {
  4. function test() {
  5. $this->def = new HTMLPurifier_AttrDef_CSS_Length();
  6. $this->assertDef('0');
  7. $this->assertDef('0px');
  8. $this->assertDef('4.5px');
  9. $this->assertDef('-4.5px');
  10. $this->assertDef('3ex');
  11. $this->assertDef('3em');
  12. $this->assertDef('3in');
  13. $this->assertDef('3cm');
  14. $this->assertDef('3mm');
  15. $this->assertDef('3pt');
  16. $this->assertDef('3pc');
  17. $this->assertDef('3PX', '3px');
  18. $this->assertDef('3', false);
  19. $this->assertDef('3miles', false);
  20. }
  21. function testNonNegative() {
  22. $this->def = new HTMLPurifier_AttrDef_CSS_Length('0');
  23. $this->assertDef('3cm');
  24. $this->assertDef('-3mm', false);
  25. }
  26. function testBounding() {
  27. $this->def = new HTMLPurifier_AttrDef_CSS_Length('-1in', '1in');
  28. $this->assertDef('1cm');
  29. $this->assertDef('-1cm');
  30. $this->assertDef('0');
  31. $this->assertDef('1em', false);
  32. }
  33. }
  34. // vim: et sw=4 sts=4