FixNesting_ErrorsTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. class HTMLPurifier_Strategy_FixNesting_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness
  3. {
  4. protected function getStrategy()
  5. {
  6. return new HTMLPurifier_Strategy_FixNesting();
  7. }
  8. public function testNodeRemoved()
  9. {
  10. $this->expectErrorCollection(E_ERROR, 'Strategy_FixNesting: Node removed');
  11. $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('ul', array(), 1));
  12. $this->invoke('<ul></ul>');
  13. }
  14. public function testNodeExcluded()
  15. {
  16. $this->expectErrorCollection(E_ERROR, 'Strategy_FixNesting: Node excluded');
  17. $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('a', array(), 2));
  18. $this->invoke("<a>\n<a></a></a>");
  19. }
  20. public function testNodeReorganized()
  21. {
  22. $this->expectErrorCollection(E_WARNING, 'Strategy_FixNesting: Node reorganized');
  23. $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('span', array(), 1));
  24. $this->invoke("<span>Valid<div>Invalid</div></span>");
  25. }
  26. public function testNoNodeReorganizedForEmptyNode()
  27. {
  28. $this->expectNoErrorCollection();
  29. $this->invoke("<span></span>");
  30. }
  31. public function testNodeContentsRemoved()
  32. {
  33. $this->expectErrorCollection(E_ERROR, 'Strategy_FixNesting: Node contents removed');
  34. $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('span', array(), 1));
  35. $this->invoke("<span><div></div></span>");
  36. }
  37. }
  38. // vim: et sw=4 sts=4