1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-08 23:26:39 +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

@@ -3,30 +3,35 @@
class HTMLPurifier_AttrTransform_BackgroundTest extends HTMLPurifier_AttrTransformHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_AttrTransform_Background();
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult( array() );
}
function testBasicTransform() {
public function testBasicTransform()
{
$this->assertResult(
array('background' => 'logo.png'),
array('style' => 'background-image:url(logo.png);')
);
}
function testPrependNewCSS() {
public function testPrependNewCSS()
{
$this->assertResult(
array('background' => 'logo.png', 'style' => 'font-weight:bold'),
array('style' => 'background-image:url(logo.png);font-weight:bold')
);
}
function testLenientTreatmentOfInvalidInput() {
public function testLenientTreatmentOfInvalidInput()
{
// notice that we rely on the CSS validator later to fix this invalid
// stuff
$this->assertResult(

View File

@@ -3,20 +3,24 @@
class HTMLPurifier_AttrTransform_BdoDirTest extends HTMLPurifier_AttrTransformHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_AttrTransform_BdoDir();
}
function testAddDefaultDir() {
public function testAddDefaultDir()
{
$this->assertResult( array(), array('dir' => 'ltr') );
}
function testPreserveExistingDir() {
public function testPreserveExistingDir()
{
$this->assertResult( array('dir' => 'rtl') );
}
function testAlternateDefault() {
public function testAlternateDefault()
{
$this->config->set('Attr.DefaultTextDir', 'rtl');
$this->assertResult(
array(),

View File

@@ -7,30 +7,35 @@
class HTMLPurifier_AttrTransform_BgColorTest extends HTMLPurifier_AttrTransformHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_AttrTransform_BgColor();
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult( array() );
}
function testBasicTransform() {
public function testBasicTransform()
{
$this->assertResult(
array('bgcolor' => '#000000'),
array('style' => 'background-color:#000000;')
);
}
function testPrependNewCSS() {
public function testPrependNewCSS()
{
$this->assertResult(
array('bgcolor' => '#000000', 'style' => 'font-weight:bold'),
array('style' => 'background-color:#000000;font-weight:bold')
);
}
function testLenientTreatmentOfInvalidInput() {
public function testLenientTreatmentOfInvalidInput()
{
// this may change when we natively support the datatype and
// validate its contents before forwarding it on
$this->assertResult(

View File

@@ -3,30 +3,35 @@
class HTMLPurifier_AttrTransform_BoolToCSSTest extends HTMLPurifier_AttrTransformHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_AttrTransform_BoolToCSS('foo', 'bar:3in;');
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult( array() );
}
function testBasicTransform() {
public function testBasicTransform()
{
$this->assertResult(
array('foo' => 'foo'),
array('style' => 'bar:3in;')
);
}
function testIgnoreValueOfBooleanAttribute() {
public function testIgnoreValueOfBooleanAttribute()
{
$this->assertResult(
array('foo' => 'no'),
array('style' => 'bar:3in;')
);
}
function testPrependCSS() {
public function testPrependCSS()
{
$this->assertResult(
array('foo' => 'foo', 'style' => 'background-color:#F00;'),
array('style' => 'bar:3in;background-color:#F00;')

View File

@@ -3,30 +3,35 @@
class HTMLPurifier_AttrTransform_BorderTest extends HTMLPurifier_AttrTransformHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_AttrTransform_Border();
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult( array() );
}
function testBasicTransform() {
public function testBasicTransform()
{
$this->assertResult(
array('border' => '1'),
array('style' => 'border:1px solid;')
);
}
function testLenientTreatmentOfInvalidInput() {
public function testLenientTreatmentOfInvalidInput()
{
$this->assertResult(
array('border' => '10%'),
array('style' => 'border:10%px solid;')
);
}
function testPrependNewCSS() {
public function testPrependNewCSS()
{
$this->assertResult(
array('border' => '23', 'style' => 'font-weight:bold;'),
array('style' => 'border:23px solid;font-weight:bold;')

View File

@@ -3,7 +3,8 @@
class HTMLPurifier_AttrTransform_EnumToCSSTest extends HTMLPurifier_AttrTransformHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
'left' => 'text-align:left;',
@@ -11,36 +12,42 @@ class HTMLPurifier_AttrTransform_EnumToCSSTest extends HTMLPurifier_AttrTransfor
));
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult( array() );
}
function testPreserveArraysWithoutInterestingAttributes() {
public function testPreserveArraysWithoutInterestingAttributes()
{
$this->assertResult( array('style' => 'font-weight:bold;') );
}
function testConvertAlignLeft() {
public function testConvertAlignLeft()
{
$this->assertResult(
array('align' => 'left'),
array('style' => 'text-align:left;')
);
}
function testConvertAlignRight() {
public function testConvertAlignRight()
{
$this->assertResult(
array('align' => 'right'),
array('style' => 'text-align:right;')
);
}
function testRemoveInvalidAlign() {
public function testRemoveInvalidAlign()
{
$this->assertResult(
array('align' => 'invalid'),
array()
);
}
function testPrependNewCSS() {
public function testPrependNewCSS()
{
$this->assertResult(
array('align' => 'left', 'style' => 'font-weight:bold;'),
array('style' => 'text-align:left;font-weight:bold;')
@@ -48,7 +55,8 @@ class HTMLPurifier_AttrTransform_EnumToCSSTest extends HTMLPurifier_AttrTransfor
}
function testCaseInsensitive() {
public function testCaseInsensitive()
{
$this->obj = new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
'right' => 'text-align:right;'
));
@@ -58,7 +66,8 @@ class HTMLPurifier_AttrTransform_EnumToCSSTest extends HTMLPurifier_AttrTransfor
);
}
function testCaseSensitive() {
public function testCaseSensitive()
{
$this->obj = new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
'right' => 'text-align:right;'
), true);

View File

@@ -3,12 +3,14 @@
class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransformHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_AttrTransform_ImgRequired();
}
function testAddMissingAttr() {
public function testAddMissingAttr()
{
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult(
array(),
@@ -16,7 +18,8 @@ class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransf
);
}
function testAlternateDefaults() {
public function testAlternateDefaults()
{
$this->config->set('Attr.DefaultInvalidImage', 'blank.png');
$this->config->set('Attr.DefaultInvalidImageAlt', 'Pawned!');
$this->config->set('Attr.DefaultImageAlt', 'not pawned');
@@ -27,14 +30,16 @@ class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransf
);
}
function testGenerateAlt() {
public function testGenerateAlt()
{
$this->assertResult(
array('src' => '/path/to/foobar.png'),
array('src' => '/path/to/foobar.png', 'alt' => 'foobar.png')
);
}
function testAddDefaultSrc() {
public function testAddDefaultSrc()
{
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult(
array('alt' => 'intrigue'),
@@ -42,7 +47,8 @@ class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransf
);
}
function testAddDefaultAlt() {
public function testAddDefaultAlt()
{
$this->config->set('Attr.DefaultImageAlt', 'default');
$this->assertResult(
array('src' => ''),

View File

@@ -3,37 +3,43 @@
class HTMLPurifier_AttrTransform_ImgSpaceTest extends HTMLPurifier_AttrTransformHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_AttrTransform_ImgSpace('vspace');
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult( array() );
}
function testVerticalBasicUsage() {
public function testVerticalBasicUsage()
{
$this->assertResult(
array('vspace' => '1'),
array('style' => 'margin-top:1px;margin-bottom:1px;')
);
}
function testLenientHandlingOfInvalidInput() {
public function testLenientHandlingOfInvalidInput()
{
$this->assertResult(
array('vspace' => '10%'),
array('style' => 'margin-top:10%px;margin-bottom:10%px;')
);
}
function testPrependNewCSS() {
public function testPrependNewCSS()
{
$this->assertResult(
array('vspace' => '23', 'style' => 'font-weight:bold;'),
array('style' => 'margin-top:23px;margin-bottom:23px;font-weight:bold;')
);
}
function testHorizontalBasicUsage() {
public function testHorizontalBasicUsage()
{
$this->obj = new HTMLPurifier_AttrTransform_ImgSpace('hspace');
$this->assertResult(
array('hspace' => '1'),
@@ -41,7 +47,8 @@ class HTMLPurifier_AttrTransform_ImgSpaceTest extends HTMLPurifier_AttrTransform
);
}
function testInvalidConstructionParameter() {
public function testInvalidConstructionParameter()
{
$this->expectError('ispace is not valid space attribute');
$this->obj = new HTMLPurifier_AttrTransform_ImgSpace('ispace');
$this->assertResult(

View File

@@ -3,20 +3,24 @@
class HTMLPurifier_AttrTransform_InputTest extends HTMLPurifier_AttrTransformHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_AttrTransform_Input();
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult(array());
}
function testInvalidCheckedWithEmpty() {
public function testInvalidCheckedWithEmpty()
{
$this->assertResult(array('checked' => 'checked'), array());
}
function testInvalidCheckedWithPassword() {
public function testInvalidCheckedWithPassword()
{
$this->assertResult(array(
'checked' => 'checked',
'type' => 'password'
@@ -25,7 +29,8 @@ class HTMLPurifier_AttrTransform_InputTest extends HTMLPurifier_AttrTransformHar
));
}
function testValidCheckedWithUcCheckbox() {
public function testValidCheckedWithUcCheckbox()
{
$this->assertResult(array(
'checked' => 'checked',
'type' => 'CHECKBOX',
@@ -33,7 +38,8 @@ class HTMLPurifier_AttrTransform_InputTest extends HTMLPurifier_AttrTransformHar
));
}
function testInvalidMaxlength() {
public function testInvalidMaxlength()
{
$this->assertResult(array(
'maxlength' => '10',
'type' => 'checkbox',
@@ -44,7 +50,8 @@ class HTMLPurifier_AttrTransform_InputTest extends HTMLPurifier_AttrTransformHar
));
}
function testValidMaxLength() {
public function testValidMaxLength()
{
$this->assertResult(array(
'maxlength' => '10',
));
@@ -52,7 +59,8 @@ class HTMLPurifier_AttrTransform_InputTest extends HTMLPurifier_AttrTransformHar
// these two are really bad test-cases
function testSizeWithCheckbox() {
public function testSizeWithCheckbox()
{
$this->assertResult(array(
'type' => 'checkbox',
'value' => 'foo',
@@ -64,7 +72,8 @@ class HTMLPurifier_AttrTransform_InputTest extends HTMLPurifier_AttrTransformHar
));
}
function testSizeWithText() {
public function testSizeWithText()
{
$this->assertResult(array(
'type' => 'password',
'size' => '100px', // spurious value, to indicate no validation takes place
@@ -74,13 +83,15 @@ class HTMLPurifier_AttrTransform_InputTest extends HTMLPurifier_AttrTransformHar
));
}
function testInvalidSrc() {
public function testInvalidSrc()
{
$this->assertResult(array(
'src' => 'img.png',
), array());
}
function testMissingValue() {
public function testMissingValue()
{
$this->assertResult(array(
'type' => 'checkbox',
), array(

View File

@@ -4,37 +4,43 @@ class HTMLPurifier_AttrTransform_LangTest
extends HTMLPurifier_AttrTransformHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_AttrTransform_Lang();
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult(array());
}
function testCopyLangToXMLLang() {
public function testCopyLangToXMLLang()
{
$this->assertResult(
array('lang' => 'en'),
array('lang' => 'en', 'xml:lang' => 'en')
);
}
function testPreserveAttributes() {
public function testPreserveAttributes()
{
$this->assertResult(
array('src' => 'vert.png', 'lang' => 'fr'),
array('src' => 'vert.png', 'lang' => 'fr', 'xml:lang' => 'fr')
);
}
function testCopyXMLLangToLang() {
public function testCopyXMLLangToLang()
{
$this->assertResult(
array('xml:lang' => 'en'),
array('xml:lang' => 'en', 'lang' => 'en')
);
}
function testXMLLangOverridesLang() {
public function testXMLLangOverridesLang()
{
$this->assertResult(
array('lang' => 'fr', 'xml:lang' => 'de'),
array('lang' => 'de', 'xml:lang' => 'de')

View File

@@ -3,37 +3,43 @@
class HTMLPurifier_AttrTransform_LengthTest extends HTMLPurifier_AttrTransformHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_AttrTransform_Length('width');
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult( array() );
}
function testTransformPixel() {
public function testTransformPixel()
{
$this->assertResult(
array('width' => '10'),
array('style' => 'width:10px;')
);
}
function testTransformPercentage() {
public function testTransformPercentage()
{
$this->assertResult(
array('width' => '10%'),
array('style' => 'width:10%;')
);
}
function testPrependNewCSS() {
public function testPrependNewCSS()
{
$this->assertResult(
array('width' => '10%', 'style' => 'font-weight:bold'),
array('style' => 'width:10%;font-weight:bold')
);
}
function testLenientTreatmentOfInvalidInput() {
public function testLenientTreatmentOfInvalidInput()
{
$this->assertResult(
array('width' => 'asdf'),
array('style' => 'width:asdf;')

View File

@@ -3,7 +3,8 @@
class HTMLPurifier_AttrTransform_NameSyncTest extends HTMLPurifier_AttrTransformHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_AttrTransform_NameSync();
$this->accumulator = new HTMLPurifier_IDAccumulator();
@@ -11,23 +12,27 @@ class HTMLPurifier_AttrTransform_NameSyncTest extends HTMLPurifier_AttrTransform
$this->config->set('Attr.EnableID', true);
}
function testEmpty() {
public function testEmpty()
{
$this->assertResult( array() );
}
function testAllowSame() {
public function testAllowSame()
{
$this->assertResult(
array('name' => 'free', 'id' => 'free')
);
}
function testAllowDifferent() {
public function testAllowDifferent()
{
$this->assertResult(
array('name' => 'tryit', 'id' => 'thisgood')
);
}
function testCheckName() {
public function testCheckName()
{
$this->accumulator->add('notok');
$this->assertResult(
array('name' => 'notok', 'id' => 'ok'),

View File

@@ -3,23 +3,27 @@
class HTMLPurifier_AttrTransform_NameTest extends HTMLPurifier_AttrTransformHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_AttrTransform_Name();
}
function testEmpty() {
public function testEmpty()
{
$this->assertResult( array() );
}
function testTransformNameToID() {
public function testTransformNameToID()
{
$this->assertResult(
array('name' => 'free'),
array('id' => 'free')
);
}
function testExistingIDOverridesName() {
public function testExistingIDOverridesName()
{
$this->assertResult(
array('name' => 'tryit', 'id' => 'tobad'),
array('id' => 'tobad')