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.

EnumToCSSTest.php 1.9KB

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