mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-03 20:58:11 +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:
committed by
Edward Z. Yang
parent
19eee14899
commit
fac747bdbd
@@ -8,12 +8,14 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
*/
|
||||
private $_entity_lookup;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->config->set('Output.Newline', "\n");
|
||||
}
|
||||
@@ -21,24 +23,28 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
/**
|
||||
* Creates a generator based on config and context member variables.
|
||||
*/
|
||||
protected function createGenerator() {
|
||||
protected function createGenerator()
|
||||
{
|
||||
return new HTMLPurifier_Generator($this->config, $this->context);
|
||||
}
|
||||
|
||||
protected function assertGenerateFromToken($token, $html) {
|
||||
protected function assertGenerateFromToken($token, $html)
|
||||
{
|
||||
$generator = $this->createGenerator();
|
||||
$result = $generator->generateFromToken($token);
|
||||
$this->assertIdentical($result, $html);
|
||||
}
|
||||
|
||||
function test_generateFromToken_text() {
|
||||
public function test_generateFromToken_text()
|
||||
{
|
||||
$this->assertGenerateFromToken(
|
||||
new HTMLPurifier_Token_Text('Foobar.<>'),
|
||||
'Foobar.<>'
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateFromToken_startWithAttr() {
|
||||
public function test_generateFromToken_startWithAttr()
|
||||
{
|
||||
$this->assertGenerateFromToken(
|
||||
new HTMLPurifier_Token_Start('a',
|
||||
array('href' => 'dyn?a=foo&b=bar')
|
||||
@@ -47,14 +53,16 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateFromToken_end() {
|
||||
public function test_generateFromToken_end()
|
||||
{
|
||||
$this->assertGenerateFromToken(
|
||||
new HTMLPurifier_Token_End('b'),
|
||||
'</b>'
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateFromToken_emptyWithAttr() {
|
||||
public function test_generateFromToken_emptyWithAttr()
|
||||
{
|
||||
$this->assertGenerateFromToken(
|
||||
new HTMLPurifier_Token_Empty('br',
|
||||
array('style' => 'font-family:"Courier New";')
|
||||
@@ -63,26 +71,30 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateFromToken_startNoAttr() {
|
||||
public function test_generateFromToken_startNoAttr()
|
||||
{
|
||||
$this->assertGenerateFromToken(
|
||||
new HTMLPurifier_Token_Start('asdf'),
|
||||
'<asdf>'
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateFromToken_emptyNoAttr() {
|
||||
public function test_generateFromToken_emptyNoAttr()
|
||||
{
|
||||
$this->assertGenerateFromToken(
|
||||
new HTMLPurifier_Token_Empty('br'),
|
||||
'<br />'
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateFromToken_error() {
|
||||
public function test_generateFromToken_error()
|
||||
{
|
||||
$this->expectError('Cannot generate HTML from non-HTMLPurifier_Token object');
|
||||
$this->assertGenerateFromToken( null, '' );
|
||||
}
|
||||
|
||||
function test_generateFromToken_unicode() {
|
||||
public function test_generateFromToken_unicode()
|
||||
{
|
||||
$theta_char = $this->_entity_lookup->table['theta'];
|
||||
$this->assertGenerateFromToken(
|
||||
new HTMLPurifier_Token_Text($theta_char),
|
||||
@@ -90,14 +102,16 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateFromToken_backtick() {
|
||||
public function test_generateFromToken_backtick()
|
||||
{
|
||||
$this->assertGenerateFromToken(
|
||||
new HTMLPurifier_Token_Start('img', array('alt' => '`foo')),
|
||||
'<img alt="`foo ">'
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateFromToken_backtickDisabled() {
|
||||
public function test_generateFromToken_backtickDisabled()
|
||||
{
|
||||
$this->config->set('Output.FixInnerHTML', false);
|
||||
$this->assertGenerateFromToken(
|
||||
new HTMLPurifier_Token_Start('img', array('alt' => '`')),
|
||||
@@ -105,52 +119,60 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateFromToken_backtickNoChange() {
|
||||
public function test_generateFromToken_backtickNoChange()
|
||||
{
|
||||
$this->assertGenerateFromToken(
|
||||
new HTMLPurifier_Token_Start('img', array('alt' => '`foo` bar')),
|
||||
'<img alt="`foo` bar">'
|
||||
);
|
||||
}
|
||||
|
||||
function assertGenerateAttributes($attr, $expect, $element = false) {
|
||||
public function assertGenerateAttributes($attr, $expect, $element = false)
|
||||
{
|
||||
$generator = $this->createGenerator();
|
||||
$result = $generator->generateAttributes($attr, $element);
|
||||
$this->assertIdentical($result, $expect);
|
||||
}
|
||||
|
||||
function test_generateAttributes_blank() {
|
||||
public function test_generateAttributes_blank()
|
||||
{
|
||||
$this->assertGenerateAttributes(array(), '');
|
||||
}
|
||||
|
||||
function test_generateAttributes_basic() {
|
||||
public function test_generateAttributes_basic()
|
||||
{
|
||||
$this->assertGenerateAttributes(
|
||||
array('href' => 'dyn?a=foo&b=bar'),
|
||||
'href="dyn?a=foo&b=bar"'
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateAttributes_doubleQuote() {
|
||||
public function test_generateAttributes_doubleQuote()
|
||||
{
|
||||
$this->assertGenerateAttributes(
|
||||
array('style' => 'font-family:"Courier New";'),
|
||||
'style="font-family:"Courier New";"'
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateAttributes_singleQuote() {
|
||||
public function test_generateAttributes_singleQuote()
|
||||
{
|
||||
$this->assertGenerateAttributes(
|
||||
array('style' => 'font-family:\'Courier New\';'),
|
||||
'style="font-family:\'Courier New\';"'
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateAttributes_multiple() {
|
||||
public function test_generateAttributes_multiple()
|
||||
{
|
||||
$this->assertGenerateAttributes(
|
||||
array('src' => 'picture.jpg', 'alt' => 'Short & interesting'),
|
||||
'src="picture.jpg" alt="Short & interesting"'
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateAttributes_specialChar() {
|
||||
public function test_generateAttributes_specialChar()
|
||||
{
|
||||
$theta_char = $this->_entity_lookup->table['theta'];
|
||||
$this->assertGenerateAttributes(
|
||||
array('title' => 'Theta is ' . $theta_char),
|
||||
@@ -159,15 +181,16 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
}
|
||||
|
||||
|
||||
function test_generateAttributes_minimized() {
|
||||
public function test_generateAttributes_minimized()
|
||||
{
|
||||
$this->config->set('HTML.Doctype', 'HTML 4.01 Transitional');
|
||||
$this->assertGenerateAttributes(
|
||||
array('compact' => 'compact'), 'compact', 'menu'
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateFromTokens() {
|
||||
|
||||
public function test_generateFromTokens()
|
||||
{
|
||||
$this->assertGeneration(
|
||||
array(
|
||||
new HTMLPurifier_Token_Start('b'),
|
||||
@@ -179,13 +202,15 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
|
||||
}
|
||||
|
||||
protected function assertGeneration($tokens, $expect) {
|
||||
protected function assertGeneration($tokens, $expect)
|
||||
{
|
||||
$generator = new HTMLPurifier_Generator($this->config, $this->context);
|
||||
$result = $generator->generateFromTokens($tokens);
|
||||
$this->assertIdentical($expect, $result);
|
||||
}
|
||||
|
||||
function test_generateFromTokens_Scripting() {
|
||||
public function test_generateFromTokens_Scripting()
|
||||
{
|
||||
$this->assertGeneration(
|
||||
array(
|
||||
new HTMLPurifier_Token_Start('script'),
|
||||
@@ -196,7 +221,8 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateFromTokens_Scripting_missingCloseTag() {
|
||||
public function test_generateFromTokens_Scripting_missingCloseTag()
|
||||
{
|
||||
$this->assertGeneration(
|
||||
array(
|
||||
new HTMLPurifier_Token_Start('script'),
|
||||
@@ -206,7 +232,8 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateFromTokens_Scripting_doubleBlock() {
|
||||
public function test_generateFromTokens_Scripting_doubleBlock()
|
||||
{
|
||||
$this->assertGeneration(
|
||||
array(
|
||||
new HTMLPurifier_Token_Start('script'),
|
||||
@@ -218,7 +245,8 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateFromTokens_Scripting_disableWrapper() {
|
||||
public function test_generateFromTokens_Scripting_disableWrapper()
|
||||
{
|
||||
$this->config->set('Output.CommentScriptContents', false);
|
||||
$this->assertGeneration(
|
||||
array(
|
||||
@@ -230,7 +258,8 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
|
||||
function test_generateFromTokens_XHTMLoff() {
|
||||
public function test_generateFromTokens_XHTMLoff()
|
||||
{
|
||||
$this->config->set('HTML.XHTML', false);
|
||||
|
||||
// omit trailing slash
|
||||
@@ -251,7 +280,8 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
|
||||
}
|
||||
|
||||
function test_generateFromTokens_TidyFormat() {
|
||||
public function test_generateFromTokens_TidyFormat()
|
||||
{
|
||||
// abort test if tidy isn't loaded
|
||||
if (!extension_loaded('tidy')) return;
|
||||
|
||||
@@ -273,7 +303,8 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
|
||||
}
|
||||
|
||||
function test_generateFromTokens_sortAttr() {
|
||||
public function test_generateFromTokens_sortAttr()
|
||||
{
|
||||
$this->config->set('Output.SortAttr', true);
|
||||
|
||||
$this->assertGeneration(
|
||||
|
Reference in New Issue
Block a user