TableTest.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. // we're using empty tags to compact the tests: under real circumstances
  3. // there would be contents in them
  4. class HTMLPurifier_ChildDef_TableTest extends HTMLPurifier_ChildDefHarness
  5. {
  6. function setUp() {
  7. parent::setUp();
  8. $this->obj = new HTMLPurifier_ChildDef_Table();
  9. }
  10. function testEmptyInput() {
  11. $this->assertResult('', false);
  12. }
  13. function testSingleRow() {
  14. $this->assertResult('<tr />');
  15. }
  16. function testComplexContents() {
  17. $this->assertResult('<caption /><col /><thead /><tfoot /><tbody>'.
  18. '<tr><td>asdf</td></tr></tbody>');
  19. $this->assertResult('<col /><col /><col /><tr />');
  20. }
  21. function testReorderContents() {
  22. $this->assertResult(
  23. '<col /><colgroup /><tbody /><tfoot /><thead /><tr>1</tr><caption /><tr />',
  24. '<caption /><col /><colgroup /><thead /><tfoot /><tbody /><tbody><tr>1</tr><tr /></tbody>');
  25. }
  26. function testXhtml11Illegal() {
  27. $this->assertResult(
  28. '<thead><tr><th>a</th></tr></thead><tr><td>a</td></tr>',
  29. '<thead><tr><th>a</th></tr></thead><tbody><tr><td>a</td></tr></tbody>'
  30. );
  31. }
  32. function testTrOverflowAndClose() {
  33. $this->assertResult(
  34. '<tr><td>a</td></tr><tr><td>b</td></tr><tbody><tr><td>c</td></tr></tbody><tr><td>d</td></tr>',
  35. '<tbody><tr><td>a</td></tr><tr><td>b</td></tr></tbody><tbody><tr><td>c</td></tr></tbody><tbody><tr><td>d</td></tr></tbody>'
  36. );
  37. }
  38. function testDuplicateProcessing() {
  39. $this->assertResult(
  40. '<caption>1</caption><caption /><tbody /><tbody /><tfoot>1</tfoot><tfoot />',
  41. '<caption>1</caption><tfoot>1</tfoot><tbody /><tbody /><tbody />'
  42. );
  43. }
  44. function testRemoveText() {
  45. $this->assertResult('foo', false);
  46. }
  47. function testStickyWhitespaceOnTr() {
  48. $this->config->set('Output.Newline', "\n");
  49. $this->assertResult("\n <tr />\n <tr />\n ");
  50. }
  51. function testStickyWhitespaceOnTSection() {
  52. $this->config->set('Output.Newline', "\n");
  53. $this->assertResult(
  54. "\n\t<tbody />\n\t\t<tfoot />\n\t\t\t",
  55. "\n\t\t<tfoot />\n\t<tbody />\n\t\t\t"
  56. );
  57. }
  58. }
  59. // vim: et sw=4 sts=4