LengthTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. class HTMLPurifier_AttrTransform_LengthTest extends HTMLPurifier_AttrTransformHarness
  3. {
  4. function setUp() {
  5. parent::setUp();
  6. $this->obj = new HTMLPurifier_AttrTransform_Length('width');
  7. }
  8. function testEmptyInput() {
  9. $this->assertResult( array() );
  10. }
  11. function testTransformPixel() {
  12. $this->assertResult(
  13. array('width' => '10'),
  14. array('style' => 'width:10px;')
  15. );
  16. }
  17. function testTransformPercentage() {
  18. $this->assertResult(
  19. array('width' => '10%'),
  20. array('style' => 'width:10%;')
  21. );
  22. }
  23. function testPrependNewCSS() {
  24. $this->assertResult(
  25. array('width' => '10%', 'style' => 'font-weight:bold'),
  26. array('style' => 'width:10%;font-weight:bold')
  27. );
  28. }
  29. function testLenientTreatmentOfInvalidInput() {
  30. $this->assertResult(
  31. array('width' => 'asdf'),
  32. array('style' => 'width:asdf;')
  33. );
  34. }
  35. }
  36. // vim: et sw=4 sts=4