FixNesting_ErrorsTest.php 1.4 KB

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