PixelsTest.php 985 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. class HTMLPurifier_AttrDef_HTML_PixelsTest extends HTMLPurifier_AttrDefHarness
  3. {
  4. function setup() {
  5. $this->def = new HTMLPurifier_AttrDef_HTML_Pixels();
  6. }
  7. function test() {
  8. $this->assertDef('1');
  9. $this->assertDef('0');
  10. $this->assertDef('2px', '2'); // rm px suffix
  11. $this->assertDef('dfs', false); // totally invalid value
  12. // conceivably we could repair this value, but we won't for now
  13. $this->assertDef('9in', false);
  14. // test trim
  15. $this->assertDef(' 45 ', '45');
  16. // no negatives
  17. $this->assertDef('-2', '0');
  18. // remove empty
  19. $this->assertDef('', false);
  20. // round down
  21. $this->assertDef('4.9', '4');
  22. }
  23. function test_make() {
  24. $factory = new HTMLPurifier_AttrDef_HTML_Pixels();
  25. $this->def = $factory->make('30');
  26. $this->assertDef('25');
  27. $this->assertDef('35', '30');
  28. }
  29. }
  30. // vim: et sw=4 sts=4