2006-11-22 18:55:15 +00:00
|
|
|
<?php
|
|
|
|
|
2007-08-07 05:38:22 +00:00
|
|
|
// we're using empty tags to compact the tests: under real circumstances
|
|
|
|
// there would be contents in them
|
|
|
|
|
2006-11-22 18:55:15 +00:00
|
|
|
class HTMLPurifier_ChildDef_TableTest extends HTMLPurifier_ChildDefHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-06 06:22:23 +00:00
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
2006-11-22 18:55:15 +00:00
|
|
|
$this->obj = new HTMLPurifier_ChildDef_Table();
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-07 05:38:22 +00:00
|
|
|
function testEmptyInput() {
|
2006-11-22 18:55:15 +00:00
|
|
|
$this->assertResult('', false);
|
2007-08-07 05:38:22 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-07 05:38:22 +00:00
|
|
|
function testSingleRow() {
|
2006-11-22 18:55:15 +00:00
|
|
|
$this->assertResult('<tr />');
|
2007-08-07 05:38:22 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-07 05:38:22 +00:00
|
|
|
function testComplexContents() {
|
2006-11-22 18:55:15 +00:00
|
|
|
$this->assertResult('<caption /><col /><thead /><tfoot /><tbody>'.
|
|
|
|
'<tr><td>asdf</td></tr></tbody>');
|
|
|
|
$this->assertResult('<col /><col /><col /><tr />');
|
2007-08-07 05:38:22 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-07 05:38:22 +00:00
|
|
|
function testReorderContents() {
|
2006-11-22 18:55:15 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<col /><colgroup /><tbody /><tfoot /><thead /><tr>1</tr><caption /><tr />',
|
2011-12-26 06:49:26 +00:00
|
|
|
'<caption /><col /><colgroup /><thead /><tfoot /><tbody /><tbody><tr>1</tr><tr /></tbody>');
|
|
|
|
}
|
|
|
|
|
|
|
|
function testXhtml11Illegal() {
|
|
|
|
$this->assertResult(
|
|
|
|
'<thead><tr><th>a</th></tr></thead><tr><td>a</td></tr>',
|
|
|
|
'<thead><tr><th>a</th></tr></thead><tbody><tr><td>a</td></tr></tbody>'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testTrOverflowAndClose() {
|
|
|
|
$this->assertResult(
|
|
|
|
'<tr><td>a</td></tr><tr><td>b</td></tr><tbody><tr><td>c</td></tr></tbody><tr><td>d</td></tr>',
|
|
|
|
'<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>'
|
|
|
|
);
|
2007-08-07 05:38:22 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-07 05:38:22 +00:00
|
|
|
function testDuplicateProcessing() {
|
2006-11-22 18:55:15 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<caption>1</caption><caption /><tbody /><tbody /><tfoot>1</tfoot><tfoot />',
|
|
|
|
'<caption>1</caption><tfoot>1</tfoot><tbody /><tbody /><tbody />'
|
|
|
|
);
|
2007-08-07 05:38:22 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-07 05:38:22 +00:00
|
|
|
function testRemoveText() {
|
2006-11-22 18:55:15 +00:00
|
|
|
$this->assertResult('foo', false);
|
2007-08-07 05:38:22 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-07 05:38:22 +00:00
|
|
|
function testStickyWhitespaceOnTr() {
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('Output.Newline', "\n");
|
2007-08-07 05:38:22 +00:00
|
|
|
$this->assertResult("\n <tr />\n <tr />\n ");
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-07 05:38:22 +00:00
|
|
|
function testStickyWhitespaceOnTSection() {
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('Output.Newline', "\n");
|
2006-11-22 18:55:15 +00:00
|
|
|
$this->assertResult(
|
|
|
|
"\n\t<tbody />\n\t\t<tfoot />\n\t\t\t",
|
2007-08-07 05:38:22 +00:00
|
|
|
"\n\t\t<tfoot />\n\t<tbody />\n\t\t\t"
|
2006-11-22 18:55:15 +00:00
|
|
|
);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-11-22 18:55:15 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-11-22 18:55:15 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|