Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

83 lines
1.9KB

  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