From a4181a80d718e15f017d43d352bf1235cd420d01 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Tue, 15 Apr 2008 03:33:09 +0000 Subject: [PATCH] Various fixes: - Resync standalone with includes - Fix error queue code - Fix heisenbug with flush and certain definition error messages - Fix premature $end in ini files - Make $php config variable actually do something git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1659 48356398-32a2-884e-a903-53898d9a118a --- maintenance/generate-standalone.php | 5 ++++- .../HTMLPurifier/ChildDef/StrictBlockquoteTest.php | 3 ++- tests/HTMLPurifier/ConfigTest-create.ini | 2 +- tests/HTMLPurifier/ConfigTest-finalize.ini | 2 +- tests/HTMLPurifier/ConfigTest-loadIni.ini | 2 +- tests/HTMLPurifier/Strategy/FixNestingTest.php | 3 ++- tests/common.php | 5 ++--- tests/index.php | 4 +++- tests/multitest.php | 14 +++++++------- 9 files changed, 23 insertions(+), 17 deletions(-) diff --git a/maintenance/generate-standalone.php b/maintenance/generate-standalone.php index 8c6af4e4..d5a631a0 100755 --- a/maintenance/generate-standalone.php +++ b/maintenance/generate-standalone.php @@ -133,12 +133,15 @@ $FS->rmdirr('standalone'); // ensure a clean copy // data files $FS->mkdirr('standalone/HTMLPurifier/DefinitionCache/Serializer'); -make_dir_standalone('HTMLPurifier/EntityLookup'); +make_file_standalone('HTMLPurifier/EntityLookup/entities.ser'); make_file_standalone('HTMLPurifier/ConfigSchema/schema.ser'); // non-standard inclusion setup +make_dir_standalone('HTMLPurifier/ConfigSchema'); make_dir_standalone('HTMLPurifier/Language'); make_dir_standalone('HTMLPurifier/Filter'); +make_dir_standalone('HTMLPurifier/Printer'); +make_file_standalone('HTMLPurifier/Printer.php'); make_file_standalone('HTMLPurifier/Lexer/PH5P.php'); make_file_standalone('HTMLPurifier/Lexer/PEARSax3.php'); diff --git a/tests/HTMLPurifier/ChildDef/StrictBlockquoteTest.php b/tests/HTMLPurifier/ChildDef/StrictBlockquoteTest.php index 60cf50f3..4aa7acf0 100644 --- a/tests/HTMLPurifier/ChildDef/StrictBlockquoteTest.php +++ b/tests/HTMLPurifier/ChildDef/StrictBlockquoteTest.php @@ -71,9 +71,10 @@ extends HTMLPurifier_ChildDefHarness } function testError() { - // $this->expectError('Cannot use non-block element as block wrapper'); + $this->expectError('Cannot use non-block element as block wrapper'); $this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p'); $this->config->set('HTML', 'BlockWrapper', 'dav'); + $this->config->set('Cache', 'DefinitionImpl', null); $this->assertResult('Needs wrap', '

Needs wrap

'); } diff --git a/tests/HTMLPurifier/ConfigTest-create.ini b/tests/HTMLPurifier/ConfigTest-create.ini index 3441565b..5b41f3a8 100644 --- a/tests/HTMLPurifier/ConfigTest-create.ini +++ b/tests/HTMLPurifier/ConfigTest-create.ini @@ -1,2 +1,2 @@ [Cake] -Sprinkles = 42 \ No newline at end of file +Sprinkles = 42 diff --git a/tests/HTMLPurifier/ConfigTest-finalize.ini b/tests/HTMLPurifier/ConfigTest-finalize.ini index 81720463..8f1fd7e0 100644 --- a/tests/HTMLPurifier/ConfigTest-finalize.ini +++ b/tests/HTMLPurifier/ConfigTest-finalize.ini @@ -1,2 +1,2 @@ [Poem] -Meter = alexandrine \ No newline at end of file +Meter = alexandrine diff --git a/tests/HTMLPurifier/ConfigTest-loadIni.ini b/tests/HTMLPurifier/ConfigTest-loadIni.ini index 80dba594..082bb11e 100644 --- a/tests/HTMLPurifier/ConfigTest-loadIni.ini +++ b/tests/HTMLPurifier/ConfigTest-loadIni.ini @@ -1,4 +1,4 @@ [Shortcut] Copy = q Cut = t -Paste = p \ No newline at end of file +Paste = p diff --git a/tests/HTMLPurifier/Strategy/FixNestingTest.php b/tests/HTMLPurifier/Strategy/FixNestingTest.php index 908ee2b4..8035faf6 100644 --- a/tests/HTMLPurifier/Strategy/FixNestingTest.php +++ b/tests/HTMLPurifier/Strategy/FixNestingTest.php @@ -106,7 +106,8 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness function testInvalidParentError() { // test fallback to div $this->config->set('HTML', 'Parent', 'obviously-impossible'); - // $this->expectError('Cannot use unrecognized element as parent'); + $this->config->set('Cache', 'DefinitionImpl', null); + $this->expectError('Cannot use unrecognized element as parent'); $this->assertResult('
Accept
'); } diff --git a/tests/common.php b/tests/common.php index 81a0eb9f..dc786aee 100644 --- a/tests/common.php +++ b/tests/common.php @@ -215,9 +215,8 @@ function htmlpurifier_flush($php, $reporter) { function htmlpurifier_dump_error_queue() { $context = SimpleTest::getContext(); $queue = $context->get('SimpleErrorQueue'); - if ($queue && !empty($queue->_queue)) { - // replace this with something prettier - var_dump($queue->_queue); + while (($error = $queue->extract()) !== false) { + var_dump($error); } } register_shutdown_function('htmlpurifier_dump_error_queue'); diff --git a/tests/index.php b/tests/index.php index de6c8817..f2401f61 100755 --- a/tests/index.php +++ b/tests/index.php @@ -25,6 +25,8 @@ define('HTMLPurifierTest', 1); define('HTMLPURIFIER_SCHEMA_STRICT', true); // validate schemas chdir(dirname(__FILE__)); +$php = 'php'; // for safety + require 'common.php'; $AC = array(); // parameters @@ -33,7 +35,7 @@ $AC['standalone'] = false; $AC['file'] = ''; $AC['xml'] = false; $AC['dry'] = false; -$AC['php'] = 'php'; +$AC['php'] = $php; // Convenience parameters for running quicker tests; ideally all tests // should be performed. diff --git a/tests/multitest.php b/tests/multitest.php index 7a14b821..07a278a4 100644 --- a/tests/multitest.php +++ b/tests/multitest.php @@ -24,6 +24,8 @@ */ define('HTMLPurifierTest', 1); +$php = 'php'; // for safety + require_once 'common.php'; if (!SimpleReporter::inCli()) { @@ -37,7 +39,7 @@ $AC['exclude-standalone'] = false; $AC['file'] = ''; $AC['xml'] = false; $AC['quiet'] = false; -$AC['php'] = 'php'; +$AC['php'] = $php; $AC['disable-phpt'] = false; $AC['only-phpt'] = false; $aliases = array( @@ -80,7 +82,7 @@ foreach ($versions_to_test as $version) { } if (!$AC['only-phpt']) { if (!$AC['exclude-normal']) { - $test->addTestCase( + $test->add( new CliTestCase( "$phpv $version index.php --xml $flush --disable-phpt $file", $AC['quiet'], $size @@ -88,7 +90,7 @@ foreach ($versions_to_test as $version) { ); } if (!$AC['exclude-standalone']) { - $test->addTestCase( + $test->add( new CliTestCase( "$phpv $version index.php --xml $flush --standalone --disable-phpt $file", $AC['quiet'], $size @@ -97,7 +99,7 @@ foreach ($versions_to_test as $version) { } } if (!$AC['disable-phpt']) { // naming is not consistent - $test->addTestCase( + $test->add( new CliTestCase( $AC['php'] . " index.php --xml --php \"$phpv $version\" --only-phpt", $AC['quiet'], $size @@ -108,8 +110,6 @@ foreach ($versions_to_test as $version) { // This is the HTML Purifier website's test XML file. We could // add more websites, i.e. more configurations to test. -$test->addTestCase(new RemoteTestCase('http://htmlpurifier.org/dev/tests/?xml=1', 'http://htmlpurifier.org/dev/tests/?xml=1&dry=1&flush=1')); +// $test->add(new RemoteTestCase('http://htmlpurifier.org/dev/tests/?xml=1', 'http://htmlpurifier.org/dev/tests/?xml=1&dry=1&flush=1')); $test->run($reporter); - -shell_exec($AC['php'] . ' ../maintenance/flush-definition-cache.php');