1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-10-17 15:06:07 +02:00

PSR-2 reformatting PHPDoc corrections

With minor corrections.

Signed-off-by: Marcus Bointon <marcus@synchromedia.co.uk>
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
Marcus Bointon
2013-07-16 13:56:14 +02:00
committed by Edward Z. Yang
parent 19eee14899
commit fac747bdbd
433 changed files with 13302 additions and 6690 deletions

View File

@@ -5,7 +5,8 @@ class HTMLPurifier_ChildDef_ChameleonTest extends HTMLPurifier_ChildDefHarness
protected $isInline;
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_ChildDef_Chameleon(
'b | i', // allowed only when in inline context
@@ -14,21 +15,24 @@ class HTMLPurifier_ChildDef_ChameleonTest extends HTMLPurifier_ChildDefHarness
$this->context->register('IsInline', $this->isInline);
}
function testInlineAlwaysAllowed() {
public function testInlineAlwaysAllowed()
{
$this->isInline = true;
$this->assertResult(
'<b>Allowed.</b>'
);
}
function testBlockNotAllowedInInline() {
public function testBlockNotAllowedInInline()
{
$this->isInline = true;
$this->assertResult(
'<div>Not allowed.</div>', ''
);
}
function testBlockAllowedInNonInline() {
public function testBlockAllowedInNonInline()
{
$this->isInline = false;
$this->assertResult(
'<div>Allowed.</div>'

View File

@@ -3,8 +3,8 @@
class HTMLPurifier_ChildDef_CustomTest extends HTMLPurifier_ChildDefHarness
{
function test() {
public function test()
{
$this->obj = new HTMLPurifier_ChildDef_Custom('(a,b?,c*,d+,(a,b)*)');
$this->assertEqual($this->obj->elements, array('a' => true,
@@ -19,7 +19,8 @@ class HTMLPurifier_ChildDef_CustomTest extends HTMLPurifier_ChildDefHarness
}
function testNesting() {
public function testNesting()
{
$this->obj = new HTMLPurifier_ChildDef_Custom('(a,b,(c|d))+');
$this->assertEqual($this->obj->elements, array('a' => true,
'b' => true, 'c' => true, 'd' => true));
@@ -28,7 +29,8 @@ class HTMLPurifier_ChildDef_CustomTest extends HTMLPurifier_ChildDefHarness
$this->assertResult('<a /><b /><c /><d />', false);
}
function testNestedEitherOr() {
public function testNestedEitherOr()
{
$this->obj = new HTMLPurifier_ChildDef_Custom('b,(a|(c|d))+');
$this->assertEqual($this->obj->elements, array('a' => true,
'b' => true, 'c' => true, 'd' => true));
@@ -39,7 +41,8 @@ class HTMLPurifier_ChildDef_CustomTest extends HTMLPurifier_ChildDefHarness
$this->assertResult('<acd />', false);
}
function testNestedQuantifier() {
public function testNestedQuantifier()
{
$this->obj = new HTMLPurifier_ChildDef_Custom('(b,c+)*');
$this->assertEqual($this->obj->elements, array('b' => true, 'c' => true));
$this->assertResult('');
@@ -49,8 +52,8 @@ class HTMLPurifier_ChildDef_CustomTest extends HTMLPurifier_ChildDefHarness
$this->assertResult('<b /><c /><b />', false);
}
function testEitherOr() {
public function testEitherOr()
{
$this->obj = new HTMLPurifier_ChildDef_Custom('a|b');
$this->assertEqual($this->obj->elements, array('a' => true, 'b' => true));
$this->assertResult('', false);
@@ -60,8 +63,8 @@ class HTMLPurifier_ChildDef_CustomTest extends HTMLPurifier_ChildDefHarness
}
function testCommafication() {
public function testCommafication()
{
$this->obj = new HTMLPurifier_ChildDef_Custom('a,b');
$this->assertEqual($this->obj->elements, array('a' => true, 'b' => true));
$this->assertResult('<a /><b />');
@@ -69,14 +72,16 @@ class HTMLPurifier_ChildDef_CustomTest extends HTMLPurifier_ChildDefHarness
}
function testPcdata() {
public function testPcdata()
{
$this->obj = new HTMLPurifier_ChildDef_Custom('#PCDATA,a');
$this->assertEqual($this->obj->elements, array('#PCDATA' => true, 'a' => true));
$this->assertResult('foo<a />');
$this->assertResult('<a />', false);
}
function testWhitespace() {
public function testWhitespace()
{
$this->obj = new HTMLPurifier_ChildDef_Custom('a');
$this->assertEqual($this->obj->elements, array('a' => true));
$this->assertResult('foo<a />', false);

View File

@@ -3,45 +3,55 @@
class HTMLPurifier_ChildDef_ListTest extends HTMLPurifier_ChildDefHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_ChildDef_List();
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult('', false);
}
function testSingleLi() {
public function testSingleLi()
{
$this->assertResult('<li />');
}
function testSomeLi() {
public function testSomeLi()
{
$this->assertResult('<li>asdf</li><li />');
}
function testIllegal() {
public function testIllegal()
{
// XXX actually this never gets triggered in practice
$this->assertResult('<li /><b />', '<li /><li><b /></li>');
}
function testOlAtBeginning() {
public function testOlAtBeginning()
{
$this->assertResult('<ol />', '<li><ol /></li>');
}
function testOlAtBeginningWithOtherJunk() {
public function testOlAtBeginningWithOtherJunk()
{
$this->assertResult('<ol /><li />', '<li><ol /></li><li />');
}
function testOlInMiddle() {
public function testOlInMiddle()
{
$this->assertResult('<li>Foo</li><ol><li>Bar</li></ol>', '<li>Foo<ol><li>Bar</li></ol></li>');
}
function testMultipleOl() {
public function testMultipleOl()
{
$this->assertResult('<li /><ol /><ol />', '<li><ol /><ol /></li>');
}
function testUlAtBeginning() {
public function testUlAtBeginning()
{
$this->assertResult('<ul />', '<li><ul /></li>');
}

View File

@@ -3,28 +3,34 @@
class HTMLPurifier_ChildDef_OptionalTest extends HTMLPurifier_ChildDefHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_ChildDef_Optional('b | i');
}
function testBasicUsage() {
public function testBasicUsage()
{
$this->assertResult('<b>Bold text</b><img />', '<b>Bold text</b>');
}
function testRemoveForbiddenText() {
public function testRemoveForbiddenText()
{
$this->assertResult('Not allowed text', '');
}
function testEmpty() {
public function testEmpty()
{
$this->assertResult('');
}
function testWhitespace() {
public function testWhitespace()
{
$this->assertResult(' ');
}
function testMultipleWhitespace() {
public function testMultipleWhitespace()
{
$this->assertResult(' ');
}

View File

@@ -3,7 +3,8 @@
class HTMLPurifier_ChildDef_RequiredTest extends HTMLPurifier_ChildDefHarness
{
function testPrepareString() {
public function testPrepareString()
{
$def = new HTMLPurifier_ChildDef_Required('foobar | bang |gizmo');
$this->assertIdentical($def->elements,
array(
@@ -13,7 +14,8 @@ class HTMLPurifier_ChildDef_RequiredTest extends HTMLPurifier_ChildDefHarness
));
}
function testPrepareArray() {
public function testPrepareArray()
{
$def = new HTMLPurifier_ChildDef_Required(array('href', 'src'));
$this->assertIdentical($def->elements,
array(
@@ -22,16 +24,19 @@ class HTMLPurifier_ChildDef_RequiredTest extends HTMLPurifier_ChildDefHarness
));
}
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_ChildDef_Required('dt | dd');
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult('', false);
}
function testRemoveIllegalTagsAndElements() {
public function testRemoveIllegalTagsAndElements()
{
$this->assertResult(
'<dt>Term</dt>Text in an illegal location'.
'<dd>Definition</dd><b>Illegal tag</b>',
@@ -39,28 +44,33 @@ class HTMLPurifier_ChildDef_RequiredTest extends HTMLPurifier_ChildDefHarness
$this->assertResult('How do you do!', false);
}
function testIgnoreWhitespace() {
public function testIgnoreWhitespace()
{
// whitespace shouldn't trigger it
$this->assertResult("\n<dd>Definition</dd> ");
}
function testPreserveWhitespaceAfterRemoval() {
public function testPreserveWhitespaceAfterRemoval()
{
$this->assertResult(
'<dd>Definition</dd> <b></b> ',
'<dd>Definition</dd> '
);
}
function testDeleteNodeIfOnlyWhitespace() {
public function testDeleteNodeIfOnlyWhitespace()
{
$this->assertResult("\t ", false);
}
function testPCDATAAllowed() {
public function testPCDATAAllowed()
{
$this->obj = new HTMLPurifier_ChildDef_Required('#PCDATA | b');
$this->assertResult('Out <b>Bold text</b><img />', 'Out <b>Bold text</b>');
}
function testPCDATAAllowedWithEscaping() {
public function testPCDATAAllowedWithEscaping()
{
$this->obj = new HTMLPurifier_ChildDef_Required('#PCDATA | b');
$this->config->set('Core.EscapeInvalidChildren', true);
$this->assertResult(

View File

@@ -4,73 +4,86 @@ class HTMLPurifier_ChildDef_StrictBlockquoteTest
extends HTMLPurifier_ChildDefHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p');
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult('');
}
function testPreserveValidP() {
public function testPreserveValidP()
{
$this->assertResult('<p>Valid</p>');
}
function testPreserveValidDiv() {
public function testPreserveValidDiv()
{
$this->assertResult('<div>Still valid</div>');
}
function testWrapTextWithP() {
public function testWrapTextWithP()
{
$this->assertResult('Needs wrap', '<p>Needs wrap</p>');
}
function testNoWrapForWhitespaceOrValidElements() {
public function testNoWrapForWhitespaceOrValidElements()
{
$this->assertResult('<p>Do not wrap</p> <p>Whitespace</p>');
}
function testWrapTextNextToValidElements() {
public function testWrapTextNextToValidElements()
{
$this->assertResult(
'Wrap'. '<p>Do not wrap</p>',
'<p>Wrap</p><p>Do not wrap</p>'
);
}
function testWrapInlineElements() {
public function testWrapInlineElements()
{
$this->assertResult(
'<p>Do not</p>'.'<b>Wrap</b>',
'<p>Do not</p><p><b>Wrap</b></p>'
);
}
function testWrapAndRemoveInvalidTags() {
public function testWrapAndRemoveInvalidTags()
{
$this->assertResult(
'<li>Not allowed</li>Paragraph.<p>Hmm.</p>',
'<p>Not allowedParagraph.</p><p>Hmm.</p>'
);
}
function testWrapComplicatedSring() {
public function testWrapComplicatedSring()
{
$this->assertResult(
$var = 'He said<br />perhaps<br />we should <b>nuke</b> them.',
"<p>$var</p>"
);
}
function testWrapAndRemoveInvalidTagsComplex() {
public function testWrapAndRemoveInvalidTagsComplex()
{
$this->assertResult(
'<foo>Bar</foo><bas /><b>People</b>Conniving.'. '<p>Fools!</p>',
'<p>Bar'. '<b>People</b>Conniving.</p><p>Fools!</p>'
);
}
function testAlternateWrapper() {
public function testAlternateWrapper()
{
$this->config->set('HTML.BlockWrapper', 'div');
$this->assertResult('Needs wrap', '<div>Needs wrap</div>');
}
function testError() {
public function testError()
{
$this->expectError('Cannot use non-block element as block wrapper');
$this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p');
$this->config->set('HTML.BlockWrapper', 'dav');

View File

@@ -6,62 +6,73 @@
class HTMLPurifier_ChildDef_TableTest extends HTMLPurifier_ChildDefHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_ChildDef_Table();
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult('', false);
}
function testSingleRow() {
public function testSingleRow()
{
$this->assertResult('<tr />');
}
function testComplexContents() {
public function testComplexContents()
{
$this->assertResult('<caption /><col /><thead /><tfoot /><tbody>'.
'<tr><td>asdf</td></tr></tbody>');
$this->assertResult('<col /><col /><col /><tr />');
}
function testReorderContents() {
public function testReorderContents()
{
$this->assertResult(
'<col /><colgroup /><tbody /><tfoot /><thead /><tr>1</tr><caption /><tr />',
'<caption /><col /><colgroup /><thead /><tfoot /><tbody /><tbody><tr>1</tr><tr /></tbody>');
}
function testXhtml11Illegal() {
public 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() {
public 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>'
);
}
function testDuplicateProcessing() {
public function testDuplicateProcessing()
{
$this->assertResult(
'<caption>1</caption><caption /><tbody /><tbody /><tfoot>1</tfoot><tfoot />',
'<caption>1</caption><tfoot>1</tfoot><tbody /><tbody /><tbody />'
);
}
function testRemoveText() {
public function testRemoveText()
{
$this->assertResult('foo', false);
}
function testStickyWhitespaceOnTr() {
public function testStickyWhitespaceOnTr()
{
$this->config->set('Output.Newline', "\n");
$this->assertResult("\n <tr />\n <tr />\n ");
}
function testStickyWhitespaceOnTSection() {
public function testStickyWhitespaceOnTSection()
{
$this->config->set('Output.Newline', "\n");
$this->assertResult(
"\n\t<tbody />\n\t\t<tfoot />\n\t\t\t",