0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-11-09 15:28:40 +00:00

[1.6.1] Unit tests now use exclusively assertIdentical

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1024 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2007-05-05 20:17:04 +00:00
parent 6c08ca4c16
commit c5e33416d3
17 changed files with 47 additions and 46 deletions

1
NEWS
View File

@ -44,6 +44,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
. AttrTransform_TextAlign axed in favor of a more general
AttrTransform_EnumToCSS, refer to HTMLModule/TransformToStrict.php to
see how the new equivalent is implemented
. Unit tests now use exclusively assertIdentical
1.6.0, released 2007-04-01
! Support for most common deprecated attributes via transformations:

View File

@ -9,11 +9,11 @@ class HTMLPurifier_AttrDefTest extends UnitTestCase
$def = new HTMLPurifier_AttrDef();
$this->assertEqual('', $def->parseCDATA(''));
$this->assertEqual('', $def->parseCDATA("\t\n\r \t\t"));
$this->assertEqual('foo', $def->parseCDATA("\t\n\r foo\t\t"));
$this->assertEqual('ignorelinefeeds', $def->parseCDATA("ignore\nline\nfeeds"));
$this->assertEqual('translate to space', $def->parseCDATA("translate\rto\tspace"));
$this->assertIdentical('', $def->parseCDATA(''));
$this->assertIdentical('', $def->parseCDATA("\t\n\r \t\t"));
$this->assertIdentical('foo', $def->parseCDATA("\t\n\r foo\t\t"));
$this->assertIdentical('ignorelinefeeds', $def->parseCDATA("ignore\nline\nfeeds"));
$this->assertIdentical('translate to space', $def->parseCDATA("translate\rto\tspace"));
}

View File

@ -34,7 +34,7 @@ class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransf
$this->assertResult(
array('alt' => 'intrigue'),
array('src' => '', 'alt' => 'intrigue')
array('alt' => 'intrigue', 'src' => '')
);
}

View File

@ -33,7 +33,7 @@ class HTMLPurifier_AttrTransform_LangTest
// copy xml:lang to lang
$this->assertResult(
array('xml:lang' => 'en'),
array('lang' => 'en', 'xml:lang' => 'en')
array('xml:lang' => 'en', 'lang' => 'en')
);
// both set, override lang with xml:lang

View File

@ -9,7 +9,7 @@ class HTMLPurifier_ChildDef_RequiredTest extends HTMLPurifier_ChildDefHarness
function testParsing() {
$def = new HTMLPurifier_ChildDef_Required('foobar | bang |gizmo');
$this->assertEqual($def->elements,
$this->assertIdentical($def->elements,
array(
'foobar' => true
,'bang' => true
@ -17,7 +17,7 @@ class HTMLPurifier_ChildDef_RequiredTest extends HTMLPurifier_ChildDefHarness
));
$def = new HTMLPurifier_ChildDef_Required(array('href', 'src'));
$this->assertEqual($def->elements,
$this->assertIdentical($def->elements,
array(
'href' => true
,'src' => true

View File

@ -164,13 +164,13 @@ class HTMLPurifier_ConfigTest extends UnitTestCase
$config = HTMLPurifier_Config::createDefault();
$this->assertEqual($config->get('Home', 'Rug'), 3);
$this->assertIdentical($config->get('Home', 'Rug'), 3);
$this->expectError('Cannot get value from aliased directive, use real name');
$config->get('Home', 'Carpet');
$config->set('Home', 'Carpet', 999);
$this->assertEqual($config->get('Home', 'Rug'), 999);
$this->assertIdentical($config->get('Home', 'Rug'), 999);
}
@ -231,7 +231,7 @@ class HTMLPurifier_ConfigTest extends UnitTestCase
$def = $config->getHTMLDefinition();
$def2 = $config->getHTMLDefinition();
$this->assertIsA($def, 'HTMLPurifier_HTMLDefinition');
$this->assertEqual($def, $def2);
$this->assertIdentical($def, $def2);
$this->assertTrue($def->setup);
// test re-calculation if HTML changes
@ -298,8 +298,8 @@ class HTMLPurifier_ConfigTest extends UnitTestCase
)
));
$this->assertEqual($config_manual, $config_loadabbr);
$this->assertEqual($config_manual, $config_loadfull);
$this->assertIdentical($config_manual, $config_loadabbr);
$this->assertIdentical($config_manual, $config_loadfull);
}
@ -314,15 +314,15 @@ class HTMLPurifier_ConfigTest extends UnitTestCase
// test flat pass-through
$created_config = HTMLPurifier_Config::create($config);
$this->assertEqual($config, $created_config);
$this->assertIdentical($config, $created_config);
// test loadArray
$created_config = HTMLPurifier_Config::create(array('Cake.Sprinkles' => 42));
$this->assertEqual($config, $created_config);
$this->assertIdentical($config, $created_config);
// test loadIni
$created_config = HTMLPurifier_Config::create(dirname(__FILE__) . '/ConfigTest-create.ini');
$this->assertEqual($config, $created_config);
$this->assertIdentical($config, $created_config);
}

View File

@ -61,7 +61,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
foreach ($inputs as $i => $input) {
$result = $this->obj->generateFromToken($input);
$this->assertEqual($result, $expect[$i]);
$this->assertIdentical($result, $expect[$i]);
paintIf($result, $result != $expect[$i]);
}
@ -90,7 +90,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
foreach ($inputs as $i => $input) {
$result = $this->obj->generateAttributes($input);
$this->assertEqual($result, $expect[$i]);
$this->assertIdentical($result, $expect[$i]);
paintIf($result, $result != $expect[$i]);
}
@ -121,7 +121,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
// normalized newlines, this probably should be put somewhere else
$result = str_replace("\r\n", "\n", $result);
$result = str_replace("\r", "\n", $result);
$this->assertEqual($expect, $result);
$this->assertIdentical($expect, $result);
}
function test_generateFromTokens_XHTMLoff() {

View File

@ -48,15 +48,15 @@ class HTMLPurifier_HTMLModuleManagerTest extends UnitTestCase
$this->manager->addModule($module);
$module_order = $this->manager->modules['Module']->order;
$module->order = $module_order;
$this->assertEqual($module, $this->manager->modules['Module']);
$this->assertIdentical($module, $this->manager->modules['Module']);
$this->manager->addModule($module2);
$module2_order = $this->manager->modules['Module2']->order;
$module2->order = $module2_order;
$this->assertEqual($module2, $this->manager->modules['Module2']);
$this->assertEqual($module_order + 1, $module2_order);
$this->assertIdentical($module2, $this->manager->modules['Module2']);
$this->assertIdentical($module_order + 1, $module2_order);
$this->assertEqual(
$this->assertIdentical(
$this->manager->collections['Default']['Generic Document 0.1'],
array('Module', 'Module2')
);

View File

@ -97,7 +97,7 @@ class HTMLPurifier_Harness extends UnitTestCase
}
}
$this->assertEqual($expect, $result);
$this->assertIdentical($expect, $result);
}

View File

@ -12,10 +12,10 @@ class HTMLPurifier_LanguageFactoryTest extends UnitTestCase
$language = $factory->create('en');
$this->assertIsA($language, 'HTMLPurifier_Language');
$this->assertEqual($language->code, 'en');
$this->assertIdentical($language->code, 'en');
// lazy loading test
$this->assertEqual(count($language->messages), 0);
$this->assertIdentical(count($language->messages), 0);
$language->load();
$this->assertNotEqual(count($language->messages), 0);
@ -30,15 +30,15 @@ class HTMLPurifier_LanguageFactoryTest extends UnitTestCase
$language = $factory->create('en-x-test');
$this->assertIsA($language, 'HTMLPurifier_Language_en_x_test');
$this->assertEqual($language->code, 'en-x-test');
$this->assertIdentical($language->code, 'en-x-test');
$language->load();
// test overloaded message
$this->assertEqual($language->getMessage('htmlpurifier'), 'HTML Purifier X');
$this->assertIdentical($language->getMessage('htmlpurifier'), 'HTML Purifier X');
// test inherited message
$this->assertEqual($language->getMessage('pizza'), 'Pizza');
$this->assertIdentical($language->getMessage('pizza'), 'Pizza');
}

View File

@ -58,7 +58,7 @@ class HTMLPurifier_Lexer_DirectLexTest extends UnitTestCase
$size = count($input);
for($i = 0; $i < $size; $i++) {
$result = $this->DirectLex->parseAttributeString($input[$i], $config, $context);
$this->assertEqual($expect[$i], $result, 'Test ' . $i . ': %s');
$this->assertIdentical($expect[$i], $result, 'Test ' . $i . ': %s');
paintIf($result, $expect[$i] != $result);
}

View File

@ -299,7 +299,7 @@ class HTMLPurifier_LexerTest extends UnitTestCase
if (!isset($config[$i])) $config[$i] = $default_config;
$result = $this->DirectLex->tokenizeHTML($input[$i], $config[$i], $default_context);
$this->assertEqual($expect[$i], $result, 'DirectLexTest '.$i.': %s');
$this->assertIdentical($expect[$i], $result, 'DirectLexTest '.$i.': %s');
paintIf($result, $expect[$i] != $result);
if ($this->_has_pear) {
@ -307,14 +307,14 @@ class HTMLPurifier_LexerTest extends UnitTestCase
$sax_result = $this->PEARSax3->tokenizeHTML($input[$i], $config[$i], $default_context);
if (!isset($sax_expect[$i])) {
// by default, assert with normal result
$this->assertEqual($expect[$i], $sax_result, 'PEARSax3Test '.$i.': %s');
$this->assertIdentical($expect[$i], $sax_result, 'PEARSax3Test '.$i.': %s');
paintIf($sax_result, $expect[$i] != $sax_result);
} elseif ($sax_expect[$i] === false) {
// assertions were turned off, optionally dump
// paintIf($sax_expect, $i == NUMBER);
} else {
// match with a custom SAX result array
$this->assertEqual($sax_expect[$i], $sax_result, 'PEARSax3Test (custom) '.$i.': %s');
$this->assertIdentical($sax_expect[$i], $sax_result, 'PEARSax3Test (custom) '.$i.': %s');
paintIf($sax_result, $sax_expect[$i] != $sax_result);
}
}
@ -323,12 +323,12 @@ class HTMLPurifier_LexerTest extends UnitTestCase
$dom_result = $this->DOMLex->tokenizeHTML($input[$i], $config[$i], $default_context);
// same structure as SAX
if (!isset($dom_expect[$i])) {
$this->assertEqual($expect[$i], $dom_result, 'DOMLexTest '.$i.': %s');
$this->assertIdentical($expect[$i], $dom_result, 'DOMLexTest '.$i.': %s');
paintIf($dom_result, $expect[$i] != $dom_result);
} elseif ($dom_expect[$i] === false) {
// paintIf($dom_result, $i == NUMBER);
} else {
$this->assertEqual($dom_expect[$i], $dom_result, 'DOMLexTest (custom) '.$i.': %s');
$this->assertIdentical($dom_expect[$i], $dom_result, 'DOMLexTest (custom) '.$i.': %s');
paintIf($dom_result, $dom_expect[$i] != $dom_result);
}
}

View File

@ -15,7 +15,7 @@ class HTMLPurifier_PercentEncoderTest extends UnitTestCase
function assertDecode($string, $expect = true) {
if ($expect === true) $expect = $string;
$this->assertEqual($this->PercentEncoder->{$this->func}($string), $expect);
$this->assertIdentical($this->PercentEncoder->{$this->func}($string), $expect);
}
function test_normalize() {

View File

@ -49,14 +49,14 @@ class HTMLPurifier_TagTransformTest extends UnitTestCase
$context->loadArray($context_array);
// start tag transform
$this->assertEqual(
$this->assertIdentical(
new HTMLPurifier_Token_Start($expect_name, $expect_added_attributes),
$transformer->transform(
new HTMLPurifier_Token_Start($name), $config, $context)
);
// start tag transform with attributes
$this->assertEqual(
$this->assertIdentical(
new HTMLPurifier_Token_Start($expect_name, $expect_attributes),
$transformer->transform(
new HTMLPurifier_Token_Start($name, $attributes),
@ -65,7 +65,7 @@ class HTMLPurifier_TagTransformTest extends UnitTestCase
);
// end tag transform
$this->assertEqual(
$this->assertIdentical(
new HTMLPurifier_Token_End($expect_name),
$transformer->transform(
new HTMLPurifier_Token_End($name), $config, $context
@ -73,7 +73,7 @@ class HTMLPurifier_TagTransformTest extends UnitTestCase
);
// empty tag transform
$this->assertEqual(
$this->assertIdentical(
new HTMLPurifier_Token_Empty($expect_name, $expect_added_attributes),
$transformer->transform(
new HTMLPurifier_Token_Empty($name), $config, $context
@ -81,7 +81,7 @@ class HTMLPurifier_TagTransformTest extends UnitTestCase
);
// empty tag transform with attributes
$this->assertEqual(
$this->assertIdentical(
new HTMLPurifier_Token_Empty($expect_name, $expect_attributes),
$transformer->transform(
new HTMLPurifier_Token_Empty($name, $attributes),

View File

@ -72,7 +72,7 @@ class HTMLPurifier_Test extends UnitTestCase
$this->purifier = new HTMLPurifier();
$this->assertEqual(
$this->assertIdentical(
$this->purifier->purifyArray(
array('Good', '<b>Sketchy', 'foo' => '<script>bad</script>')
),

View File

@ -11,7 +11,7 @@ class HTMLPurifier_TokenFactoryTest extends UnitTestCase
$regular = new HTMLPurifier_Token_Start('a', array('href' => 'about:blank'));
$generated = $factory->createStart('a', array('href' => 'about:blank'));
$this->assertEqual($regular, $generated);
$this->assertIdentical($regular, $generated);
}
}

View File

@ -12,8 +12,8 @@ class HTMLPurifier_TokenTest extends UnitTestCase
if ($expect_attr === null) $expect_attr = $attr;
$token = new HTMLPurifier_Token_Start($name, $attr);
$this->assertEqual($expect_name, $token->name);
$this->assertEqual($expect_attr, $token->attr);
$this->assertIdentical($expect_name, $token->name);
$this->assertIdentical($expect_attr, $token->attr);
}
function testConstruct() {