From f22a02dcfaa04bda3623712c6221ba036749fc08 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Tue, 30 Oct 2007 21:06:18 +0000 Subject: [PATCH] Update XHTML Compiler to also check conf/ folder and fix broken unit tests. git-svn-id: http://htmlpurifier.org/svnroot@1430 48356398-32a2-884e-a903-53898d9a118a --- XHTMLCompiler.php | 6 +++++- tests/XHTMLCompiler/FilterManagerTest.php | 3 --- tests/XHTMLCompiler/FunctionsTest.php | 3 ++- tests/XHTMLCompiler/PageTest.php | 2 ++ tests/index.php | 3 ++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/XHTMLCompiler.php b/XHTMLCompiler.php index 6557b40..a23f79a 100644 --- a/XHTMLCompiler.php +++ b/XHTMLCompiler.php @@ -64,7 +64,11 @@ class XHTMLCompiler public function loadConf() { $filters = new XHTMLCompiler_FilterManager(); require 'config.default.php'; // defaults - require 'config.php'; // user + + // user configuration + if (file_exists($f = dirname(__FILE__) . '/conf/config.php')) require $f; + if (file_exists($f = dirname(__FILE__) . '/config.php')) require $f; + $this->config = compact($this->configKeys); $this->filterManager = $filters; } diff --git a/tests/XHTMLCompiler/FilterManagerTest.php b/tests/XHTMLCompiler/FilterManagerTest.php index 94fedfb..2a61fa0 100644 --- a/tests/XHTMLCompiler/FilterManagerTest.php +++ b/tests/XHTMLCompiler/FilterManagerTest.php @@ -102,9 +102,6 @@ xmlns:proprietary="urn:foobar:foofoofoo"> // displayed accordingly $this->assertPattern('/Error/i', $text); - // assert that the xml processing instruction was scrubbed - $this->assertNoPattern('/<\?xml/', $text); - // assert that all proprietary namespaces were scrubbed $this->assertNoPattern('/proprietary/', $text); diff --git a/tests/XHTMLCompiler/FunctionsTest.php b/tests/XHTMLCompiler/FunctionsTest.php index 8871e8a..99ce31f 100644 --- a/tests/XHTMLCompiler/FunctionsTest.php +++ b/tests/XHTMLCompiler/FunctionsTest.php @@ -10,11 +10,12 @@ class XHTMLCompiler_FunctionsTest extends XHTMLCompilerHarness } function test_exception_handler() { + $this->xc->setReturnValue('getConf', 'xhtml-compiler/error.xsl', array('error_xsl')); $this->php->expect('paint', array(new PatternExpectation('/404 Not Found/'))); xhtmlcompiler_exception_handler(new XHTMLCompiler_Exception(404)); $this->php->expect('paint', array(new PatternExpectation('/WTF/'))); xhtmlcompiler_exception_handler(new XHTMLCompiler_Exception(404, 'WTF')); - $this->php->expect('paint', array(new PatternExpectation('/404 Not Found.+?Could not find the file/'))); + $this->php->expect('paint', array(new PatternExpectation('/Could not find the file/'))); xhtmlcompiler_exception_handler(new XHTMLCompiler_Exception(404, false, 'Could not find the file')); } diff --git a/tests/XHTMLCompiler/PageTest.php b/tests/XHTMLCompiler/PageTest.php index 243de7d..415f1bb 100644 --- a/tests/XHTMLCompiler/PageTest.php +++ b/tests/XHTMLCompiler/PageTest.php @@ -15,6 +15,7 @@ class XHTMLCompiler_PageTest extends XHTMLCompilerHarness array('allowed_dirs') ); $this->php->setReturnValue('realpath', '/home/user', array('.')); + $this->php->setReturnValue('realpath', '/home/user', array('./')); $this->php->setReturnValue('realpath', '/home/user', array('')); $this->php->setReturnValue('realpath', '/home/user/subdir', array('subdir')); $this->php->setReturnValue('realpath', '/home/user/flatdir', array('flatdir')); @@ -23,6 +24,7 @@ class XHTMLCompiler_PageTest extends XHTMLCompilerHarness function testConstruct() { $this->php->setReturnValue('isFile', true, array('index.xhtml')); $this->php->setReturnValue('isDir', true, array('.')); + $this->php->setReturnValue('realpath', '/home/user/index.html', array('index.html')); $page = new XHTMLCompiler_Page('index.html'); $this->assertEqual($page->getPathStem(), 'index'); } diff --git a/tests/index.php b/tests/index.php index 2d6fbf0..6cdd986 100644 --- a/tests/index.php +++ b/tests/index.php @@ -9,7 +9,8 @@ define('XHTMLCompilerTest', 1); $simpletest_location = 'simpletest/'; // reasonable guess // load SimpleTest -@include '../config-test.php'; // don't mind if it isn't there +if(file_exists($f = '../conf/config-test.php')) include $f; +if(file_exists($f = '../config-test.php')) include $f; require_once $simpletest_location . 'unit_tester.php'; require_once $simpletest_location . 'reporter.php'; require_once $simpletest_location . 'mock_objects.php'; -- 2.11.4.GIT