BackgroundPositionTest.php 2.2 KB

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