ImgSpaceTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. class HTMLPurifier_AttrTransform_ImgSpaceTest extends HTMLPurifier_AttrTransformHarness
  3. {
  4. function setUp() {
  5. parent::setUp();
  6. $this->obj = new HTMLPurifier_AttrTransform_ImgSpace('vspace');
  7. }
  8. function testEmptyInput() {
  9. $this->assertResult( array() );
  10. }
  11. function testVerticalBasicUsage() {
  12. $this->assertResult(
  13. array('vspace' => '1'),
  14. array('style' => 'margin-top:1px;margin-bottom:1px;')
  15. );
  16. }
  17. function testLenientHandlingOfInvalidInput() {
  18. $this->assertResult(
  19. array('vspace' => '10%'),
  20. array('style' => 'margin-top:10%px;margin-bottom:10%px;')
  21. );
  22. }
  23. function testPrependNewCSS() {
  24. $this->assertResult(
  25. array('vspace' => '23', 'style' => 'font-weight:bold;'),
  26. array('style' => 'margin-top:23px;margin-bottom:23px;font-weight:bold;')
  27. );
  28. }
  29. function testHorizontalBasicUsage() {
  30. $this->obj = new HTMLPurifier_AttrTransform_ImgSpace('hspace');
  31. $this->assertResult(
  32. array('hspace' => '1'),
  33. array('style' => 'margin-left:1px;margin-right:1px;')
  34. );
  35. }
  36. function testInvalidConstructionParameter() {
  37. $this->expectError('ispace is not valid space attribute');
  38. $this->obj = new HTMLPurifier_AttrTransform_ImgSpace('ispace');
  39. $this->assertResult(
  40. array('ispace' => '1'),
  41. array()
  42. );
  43. }
  44. }
  45. // vim: et sw=4 sts=4