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.

69 lines
2.2KB

  1. <?php
  2. class HTMLPurifier_AttrDef_CSS_BackgroundPositionTest extends HTMLPurifier_AttrDefHarness
  3. {
  4. public function test()
  5. {
  6. $this->def = new HTMLPurifier_AttrDef_CSS_BackgroundPosition();
  7. // explicitly cited in spec
  8. $this->assertDef('0% 0%');
  9. $this->assertDef('100% 100%');
  10. $this->assertDef('14% 84%');
  11. $this->assertDef('2cm 1cm');
  12. $this->assertDef('top');
  13. $this->assertDef('left');
  14. $this->assertDef('center');
  15. $this->assertDef('right');
  16. $this->assertDef('bottom');
  17. $this->assertDef('left top');
  18. $this->assertDef('center top');
  19. $this->assertDef('right top');
  20. $this->assertDef('left center');
  21. $this->assertDef('right center');
  22. $this->assertDef('left bottom');
  23. $this->assertDef('center bottom');
  24. $this->assertDef('right bottom');
  25. // reordered due to internal impl details
  26. $this->assertDef('top left', 'left top');
  27. $this->assertDef('top center', 'top');
  28. $this->assertDef('top right', 'right top');
  29. $this->assertDef('center left', 'left');
  30. $this->assertDef('center center', 'center');
  31. $this->assertDef('center right', 'right');
  32. $this->assertDef('bottom left', 'left bottom');
  33. $this->assertDef('bottom center', 'bottom');
  34. $this->assertDef('bottom right', 'right bottom');
  35. // more cases from the defined syntax
  36. $this->assertDef('1.32in 4ex');
  37. $this->assertDef('-14% -84.65%');
  38. $this->assertDef('-1in -4ex');
  39. $this->assertDef('-1pc 2.3%');
  40. // keyword mixing
  41. $this->assertDef('3em top');
  42. $this->assertDef('left 50%');
  43. // fixable keyword mixing
  44. $this->assertDef('top 3em', '3em top');
  45. $this->assertDef('50% left', 'left 50%');
  46. // whitespace collapsing
  47. $this->assertDef('3em top', '3em top');
  48. $this->assertDef("left\n \t foo ", 'left');
  49. // invalid uses (we're going to be strict on these)
  50. $this->assertDef('foo bar', false);
  51. $this->assertDef('left left', 'left');
  52. $this->assertDef('left right top bottom center left', 'left bottom');
  53. $this->assertDef('0fr 9%', '9%');
  54. }
  55. }
  56. // vim: et sw=4 sts=4