AttrTransformTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. Mock::generatePartial(
  3. 'HTMLPurifier_AttrTransform',
  4. 'HTMLPurifier_AttrTransformTestable',
  5. array('transform'));
  6. class HTMLPurifier_AttrTransformTest extends HTMLPurifier_Harness
  7. {
  8. function test_prependCSS() {
  9. $t = new HTMLPurifier_AttrTransformTestable();
  10. $attr = array();
  11. $t->prependCSS($attr, 'style:new;');
  12. $this->assertIdentical(array('style' => 'style:new;'), $attr);
  13. $attr = array('style' => 'style:original;');
  14. $t->prependCSS($attr, 'style:new;');
  15. $this->assertIdentical(array('style' => 'style:new;style:original;'), $attr);
  16. $attr = array('style' => 'style:original;', 'misc' => 'un-related');
  17. $t->prependCSS($attr, 'style:new;');
  18. $this->assertIdentical(array('style' => 'style:new;style:original;', 'misc' => 'un-related'), $attr);
  19. }
  20. function test_confiscateAttr() {
  21. $t = new HTMLPurifier_AttrTransformTestable();
  22. $attr = array('flavor' => 'sweet');
  23. $this->assertIdentical('sweet', $t->confiscateAttr($attr, 'flavor'));
  24. $this->assertIdentical(array(), $attr);
  25. $attr = array('flavor' => 'sweet');
  26. $this->assertIdentical(null, $t->confiscateAttr($attr, 'color'));
  27. $this->assertIdentical(array('flavor' => 'sweet'), $attr);
  28. }
  29. }
  30. // vim: et sw=4 sts=4