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.

ImgSpaceTest.php 1.6KB

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