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

Remove trailing whitespace.

Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
Edward Z. Yang
2008-12-06 02:28:20 -05:00
parent 3a6b63dff1
commit 2c955af135
476 changed files with 5595 additions and 5547 deletions

View File

@@ -2,42 +2,42 @@
class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
{
/**
* Entity lookup table to help for a few tests.
*/
private $_entity_lookup;
public function __construct() {
parent::__construct();
$this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
}
public function setUp() {
parent::setUp();
$this->config->set('Output', 'Newline', "\n");
}
/**
* Creates a generator based on config and context member variables.
*/
protected function createGenerator() {
return new HTMLPurifier_Generator($this->config, $this->context);
}
protected function assertGenerateFromToken($token, $html) {
$generator = $this->createGenerator();
$result = $generator->generateFromToken($token);
$this->assertIdentical($result, $html);
}
function test_generateFromToken_text() {
$this->assertGenerateFromToken(
new HTMLPurifier_Token_Text('Foobar.<>'),
'Foobar.&lt;&gt;'
);
}
function test_generateFromToken_startWithAttr() {
$this->assertGenerateFromToken(
new HTMLPurifier_Token_Start('a',
@@ -46,14 +46,14 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
'<a href="dyn?a=foo&amp;b=bar">'
);
}
function test_generateFromToken_end() {
$this->assertGenerateFromToken(
new HTMLPurifier_Token_End('b'),
'</b>'
);
}
function test_generateFromToken_emptyWithAttr() {
$this->assertGenerateFromToken(
new HTMLPurifier_Token_Empty('br',
@@ -62,26 +62,26 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
'<br style="font-family:&quot;Courier New&quot;;" />'
);
}
function test_generateFromToken_startNoAttr() {
$this->assertGenerateFromToken(
new HTMLPurifier_Token_Start('asdf'),
'<asdf>'
);
}
function test_generateFromToken_emptyNoAttr() {
$this->assertGenerateFromToken(
new HTMLPurifier_Token_Empty('br'),
'<br />'
);
}
function test_generateFromToken_error() {
$this->expectError('Cannot generate HTML from non-HTMLPurifier_Token object');
$this->assertGenerateFromToken( null, '' );
}
function test_generateFromToken_() {
$theta_char = $this->_entity_lookup->table['theta'];
$this->assertGenerateFromToken(
@@ -89,45 +89,45 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
$theta_char
);
}
function assertGenerateAttributes($attr, $expect, $element = false) {
$generator = $this->createGenerator();
$result = $generator->generateAttributes($attr, $element);
$this->assertIdentical($result, $expect);
}
function test_generateAttributes_blank() {
$this->assertGenerateAttributes(array(), '');
}
function test_generateAttributes_basic() {
$this->assertGenerateAttributes(
array('href' => 'dyn?a=foo&b=bar'),
'href="dyn?a=foo&amp;b=bar"'
);
}
function test_generateAttributes_doubleQuote() {
$this->assertGenerateAttributes(
array('style' => 'font-family:"Courier New";'),
'style="font-family:&quot;Courier New&quot;;"'
);
}
function test_generateAttributes_singleQuote() {
$this->assertGenerateAttributes(
array('style' => 'font-family:\'Courier New\';'),
'style="font-family:\'Courier New\';"'
);
}
function test_generateAttributes_multiple() {
$this->assertGenerateAttributes(
array('src' => 'picture.jpg', 'alt' => 'Short & interesting'),
'src="picture.jpg" alt="Short &amp; interesting"'
);
}
function test_generateAttributes_specialChar() {
$theta_char = $this->_entity_lookup->table['theta'];
$this->assertGenerateAttributes(
@@ -135,17 +135,17 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
'title="Theta is ' . $theta_char . '"'
);
}
function test_generateAttributes_minimized() {
$this->config->set('HTML', 'Doctype', 'HTML 4.01 Transitional');
$this->assertGenerateAttributes(
array('compact' => 'compact'), 'compact', 'menu'
);
}
function test_generateFromTokens() {
$this->assertGeneration(
array(
new HTMLPurifier_Token_Start('b'),
@@ -154,15 +154,15 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
),
'<b>Foobar!</b>'
);
}
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() {
$this->assertGeneration(
array(
@@ -173,7 +173,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
"<script><!--//--><![CDATA[//><!--\nalert(3 < 5);\n//--><!]]></script>"
);
}
function test_generateFromTokens_Scripting_missingCloseTag() {
$this->assertGeneration(
array(
@@ -183,7 +183,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
"<script>alert(3 &lt; 5);"
);
}
function test_generateFromTokens_Scripting_doubleBlock() {
$this->assertGeneration(
array(
@@ -195,7 +195,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
"<script>alert(3 &lt; 5);foo();</script>"
);
}
function test_generateFromTokens_Scripting_disableWrapper() {
$this->config->set('Output', 'CommentScriptContents', false);
$this->assertGeneration(
@@ -207,38 +207,38 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
"<script>alert(3 &lt; 5);</script>"
);
}
function test_generateFromTokens_XHTMLoff() {
$this->config->set('HTML', 'XHTML', false);
// omit trailing slash
$this->assertGeneration(
array( new HTMLPurifier_Token_Empty('br') ),
'<br>'
);
// there should be a test for attribute minimization, but it is
// impossible for something like that to happen due to our current
// definitions! fix it later
// namespaced attributes must be dropped
$this->assertGeneration(
array( new HTMLPurifier_Token_Start('p', array('xml:lang'=>'fr')) ),
'<p>'
);
}
function test_generateFromTokens_TidyFormat() {
// abort test if tidy isn't loaded
if (!extension_loaded('tidy')) return;
// just don't test; Tidy is exploding on me.
return;
$this->config->set('Core', 'TidyFormat', true);
$this->config->set('Output', 'Newline', "\n");
// nice wrapping please
$this->assertGeneration(
array(
@@ -248,18 +248,18 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
),
"<div>\n Text\n</div>\n"
);
}
function test_generateFromTokens_sortAttr() {
$this->config->set('Output', 'SortAttr', true);
$this->assertGeneration(
array( new HTMLPurifier_Token_Start('p', array('b'=>'c', 'a'=>'d')) ),
'<p a="d" b="c">'
);
}
}