From a9bc586e620d4e46f21780dff5c8ebab8c6856fa Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Fri, 12 Mar 2010 22:52:11 +0000 Subject: [PATCH] Force loading of Sanitizer in setUp() so defines() are always present before tests. --- includes/AutoLoader.php | 11 +++++++++++ maintenance/tests/SanitizerTest.php | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index be1374670b..4f5a9c1852 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -664,6 +664,17 @@ class AutoLoader { } } } + + /** + * Force a class to be run through the autoloader, helpful for things like + * Sanitizer that have define()s outside of their class definition. Of course + * this wouldn't be necessary if everything in MediaWiki was class-based. Sigh. + * + * @return Boolean Return the results of class_exists() so we know if we were successful + */ + static function loadClass( $class ) { + return class_exists( $class ); + } } function wfLoadAllExtensions() { diff --git a/maintenance/tests/SanitizerTest.php b/maintenance/tests/SanitizerTest.php index 886fac30a8..a12f9013f0 100644 --- a/maintenance/tests/SanitizerTest.php +++ b/maintenance/tests/SanitizerTest.php @@ -2,6 +2,10 @@ class SanitizerTest extends PHPUnit_Framework_TestCase { + function setUp() { + AutoLoader::loadClass( 'Sanitizer' ); + } + function testDecodeNamedEntities() { $this->assertEquals( "\xc3\xa9cole", -- 2.20.1