diff --git a/NEWS b/NEWS index 5906e9db..6c33ae83 100644 --- a/NEWS +++ b/NEWS @@ -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: diff --git a/tests/HTMLPurifier/AttrDefTest.php b/tests/HTMLPurifier/AttrDefTest.php index ff4ad725..1edb3747 100644 --- a/tests/HTMLPurifier/AttrDefTest.php +++ b/tests/HTMLPurifier/AttrDefTest.php @@ -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")); } diff --git a/tests/HTMLPurifier/AttrTransform/ImgRequiredTest.php b/tests/HTMLPurifier/AttrTransform/ImgRequiredTest.php index bd008625..dff045ee 100644 --- a/tests/HTMLPurifier/AttrTransform/ImgRequiredTest.php +++ b/tests/HTMLPurifier/AttrTransform/ImgRequiredTest.php @@ -34,7 +34,7 @@ class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransf $this->assertResult( array('alt' => 'intrigue'), - array('src' => '', 'alt' => 'intrigue') + array('alt' => 'intrigue', 'src' => '') ); } diff --git a/tests/HTMLPurifier/AttrTransform/LangTest.php b/tests/HTMLPurifier/AttrTransform/LangTest.php index b4800990..2e3551b3 100644 --- a/tests/HTMLPurifier/AttrTransform/LangTest.php +++ b/tests/HTMLPurifier/AttrTransform/LangTest.php @@ -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 diff --git a/tests/HTMLPurifier/ChildDef/RequiredTest.php b/tests/HTMLPurifier/ChildDef/RequiredTest.php index d19eef9b..0e8c8b1e 100644 --- a/tests/HTMLPurifier/ChildDef/RequiredTest.php +++ b/tests/HTMLPurifier/ChildDef/RequiredTest.php @@ -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 diff --git a/tests/HTMLPurifier/ConfigTest.php b/tests/HTMLPurifier/ConfigTest.php index f368f8c0..69bbf81b 100644 --- a/tests/HTMLPurifier/ConfigTest.php +++ b/tests/HTMLPurifier/ConfigTest.php @@ -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); } diff --git a/tests/HTMLPurifier/GeneratorTest.php b/tests/HTMLPurifier/GeneratorTest.php index 6bd1b59d..f16b95ed 100644 --- a/tests/HTMLPurifier/GeneratorTest.php +++ b/tests/HTMLPurifier/GeneratorTest.php @@ -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() { diff --git a/tests/HTMLPurifier/HTMLModuleManagerTest.php b/tests/HTMLPurifier/HTMLModuleManagerTest.php index 7465cf3c..380e2e48 100644 --- a/tests/HTMLPurifier/HTMLModuleManagerTest.php +++ b/tests/HTMLPurifier/HTMLModuleManagerTest.php @@ -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') ); diff --git a/tests/HTMLPurifier/Harness.php b/tests/HTMLPurifier/Harness.php index c9ccf58f..6e94e5ab 100644 --- a/tests/HTMLPurifier/Harness.php +++ b/tests/HTMLPurifier/Harness.php @@ -97,7 +97,7 @@ class HTMLPurifier_Harness extends UnitTestCase } } - $this->assertEqual($expect, $result); + $this->assertIdentical($expect, $result); } diff --git a/tests/HTMLPurifier/LanguageFactoryTest.php b/tests/HTMLPurifier/LanguageFactoryTest.php index 050d30d8..1355b5d9 100644 --- a/tests/HTMLPurifier/LanguageFactoryTest.php +++ b/tests/HTMLPurifier/LanguageFactoryTest.php @@ -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'); } diff --git a/tests/HTMLPurifier/Lexer/DirectLexTest.php b/tests/HTMLPurifier/Lexer/DirectLexTest.php index 4a2a0f16..19ec0ad0 100644 --- a/tests/HTMLPurifier/Lexer/DirectLexTest.php +++ b/tests/HTMLPurifier/Lexer/DirectLexTest.php @@ -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); } diff --git a/tests/HTMLPurifier/LexerTest.php b/tests/HTMLPurifier/LexerTest.php index c0da5b2a..5da0f599 100644 --- a/tests/HTMLPurifier/LexerTest.php +++ b/tests/HTMLPurifier/LexerTest.php @@ -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); } } diff --git a/tests/HTMLPurifier/PercentEncoderTest.php b/tests/HTMLPurifier/PercentEncoderTest.php index ef5ac869..7d014f03 100644 --- a/tests/HTMLPurifier/PercentEncoderTest.php +++ b/tests/HTMLPurifier/PercentEncoderTest.php @@ -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() { diff --git a/tests/HTMLPurifier/TagTransformTest.php b/tests/HTMLPurifier/TagTransformTest.php index ab9e6086..51317c04 100644 --- a/tests/HTMLPurifier/TagTransformTest.php +++ b/tests/HTMLPurifier/TagTransformTest.php @@ -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), diff --git a/tests/HTMLPurifier/Test.php b/tests/HTMLPurifier/Test.php index 3fa54173..0fc83b84 100644 --- a/tests/HTMLPurifier/Test.php +++ b/tests/HTMLPurifier/Test.php @@ -72,7 +72,7 @@ class HTMLPurifier_Test extends UnitTestCase $this->purifier = new HTMLPurifier(); - $this->assertEqual( + $this->assertIdentical( $this->purifier->purifyArray( array('Good', 'Sketchy', 'foo' => '') ), diff --git a/tests/HTMLPurifier/TokenFactoryTest.php b/tests/HTMLPurifier/TokenFactoryTest.php index 9995ef74..9007824f 100644 --- a/tests/HTMLPurifier/TokenFactoryTest.php +++ b/tests/HTMLPurifier/TokenFactoryTest.php @@ -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); } } diff --git a/tests/HTMLPurifier/TokenTest.php b/tests/HTMLPurifier/TokenTest.php index 6c51808e..d87b4c4c 100644 --- a/tests/HTMLPurifier/TokenTest.php +++ b/tests/HTMLPurifier/TokenTest.php @@ -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() {