BackgroundTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. class HTMLPurifier_AttrTransform_BackgroundTest extends HTMLPurifier_AttrTransformHarness
  3. {
  4. function setUp() {
  5. parent::setUp();
  6. $this->obj = new HTMLPurifier_AttrTransform_Background();
  7. }
  8. function testEmptyInput() {
  9. $this->assertResult( array() );
  10. }
  11. function testBasicTransform() {
  12. $this->assertResult(
  13. array('background' => 'logo.png'),
  14. array('style' => 'background-image:url(logo.png);')
  15. );
  16. }
  17. function testPrependNewCSS() {
  18. $this->assertResult(
  19. array('background' => 'logo.png', 'style' => 'font-weight:bold'),
  20. array('style' => 'background-image:url(logo.png);font-weight:bold')
  21. );
  22. }
  23. function testLenientTreatmentOfInvalidInput() {
  24. // notice that we rely on the CSS validator later to fix this invalid
  25. // stuff
  26. $this->assertResult(
  27. array('background' => 'logo.png);foo:('),
  28. array('style' => 'background-image:url(logo.png);foo:();')
  29. );
  30. }
  31. }
  32. // vim: et sw=4 sts=4