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.

48 lines
1017B

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