Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

RequiredTest.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. class HTMLPurifier_ChildDef_RequiredTest extends HTMLPurifier_ChildDefHarness
  3. {
  4. public function testPrepareString()
  5. {
  6. $def = new HTMLPurifier_ChildDef_Required('foobar | bang |gizmo');
  7. $this->assertIdentical($def->elements,
  8. array(
  9. 'foobar' => true
  10. ,'bang' => true
  11. ,'gizmo' => true
  12. ));
  13. }
  14. public function testPrepareArray()
  15. {
  16. $def = new HTMLPurifier_ChildDef_Required(array('href', 'src'));
  17. $this->assertIdentical($def->elements,
  18. array(
  19. 'href' => true
  20. ,'src' => true
  21. ));
  22. }
  23. public function setUp()
  24. {
  25. parent::setUp();
  26. $this->obj = new HTMLPurifier_ChildDef_Required('dt | dd');
  27. }
  28. public function testEmptyInput()
  29. {
  30. $this->assertResult('', false);
  31. }
  32. public function testRemoveIllegalTagsAndElements()
  33. {
  34. $this->assertResult(
  35. '<dt>Term</dt>Text in an illegal location'.
  36. '<dd>Definition</dd><b>Illegal tag</b>',
  37. '<dt>Term</dt><dd>Definition</dd>');
  38. $this->assertResult('How do you do!', false);
  39. }
  40. public function testIgnoreWhitespace()
  41. {
  42. // whitespace shouldn't trigger it
  43. $this->assertResult("\n<dd>Definition</dd> ");
  44. }
  45. public function testPreserveWhitespaceAfterRemoval()
  46. {
  47. $this->assertResult(
  48. '<dd>Definition</dd> <b></b> ',
  49. '<dd>Definition</dd> '
  50. );
  51. }
  52. public function testDeleteNodeIfOnlyWhitespace()
  53. {
  54. $this->assertResult("\t ", false);
  55. }
  56. public function testPCDATAAllowed()
  57. {
  58. $this->obj = new HTMLPurifier_ChildDef_Required('#PCDATA | b');
  59. $this->assertResult('Out <b>Bold text</b><img />', 'Out <b>Bold text</b>');
  60. }
  61. public function testPCDATAAllowedJump()
  62. {
  63. $this->obj = new HTMLPurifier_ChildDef_Required('#PCDATA | b');
  64. $this->assertResult('A <i>foo</i>', 'A foo');
  65. }
  66. }
  67. // vim: et sw=4 sts=4