EnumToCSSTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. class HTMLPurifier_AttrTransform_EnumToCSSTest extends HTMLPurifier_AttrTransformHarness
  3. {
  4. function setUp() {
  5. parent::setUp();
  6. $this->obj = new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
  7. 'left' => 'text-align:left;',
  8. 'right' => 'text-align:right;'
  9. ));
  10. }
  11. function testEmptyInput() {
  12. $this->assertResult( array() );
  13. }
  14. function testPreserveArraysWithoutInterestingAttributes() {
  15. $this->assertResult( array('style' => 'font-weight:bold;') );
  16. }
  17. function testConvertAlignLeft() {
  18. $this->assertResult(
  19. array('align' => 'left'),
  20. array('style' => 'text-align:left;')
  21. );
  22. }
  23. function testConvertAlignRight() {
  24. $this->assertResult(
  25. array('align' => 'right'),
  26. array('style' => 'text-align:right;')
  27. );
  28. }
  29. function testRemoveInvalidAlign() {
  30. $this->assertResult(
  31. array('align' => 'invalid'),
  32. array()
  33. );
  34. }
  35. function testPrependNewCSS() {
  36. $this->assertResult(
  37. array('align' => 'left', 'style' => 'font-weight:bold;'),
  38. array('style' => 'text-align:left;font-weight:bold;')
  39. );
  40. }
  41. function testCaseInsensitive() {
  42. $this->obj = new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
  43. 'right' => 'text-align:right;'
  44. ));
  45. $this->assertResult(
  46. array('align' => 'RIGHT'),
  47. array('style' => 'text-align:right;')
  48. );
  49. }
  50. function testCaseSensitive() {
  51. $this->obj = new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
  52. 'right' => 'text-align:right;'
  53. ), true);
  54. $this->assertResult(
  55. array('align' => 'RIGHT'),
  56. array()
  57. );
  58. }
  59. }
  60. // vim: et sw=4 sts=4