From 29ed343b4c57a662eee2c19bacac1f12198debcf Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Mon, 1 Feb 2010 04:55:15 +0000 Subject: [PATCH] Fix parsertests so that they work even when server-side thumbnailing isn't configured. --- includes/MessageCache.php | 20 ++++++++++-------- includes/Namespace.php | 1 + includes/Title.php | 7 ++++++- maintenance/parserTests.inc | 1 + maintenance/parserTests.txt | 30 +++++++++++++-------------- tests/MediaWikiParserTest.php | 39 ----------------------------------- tests/MediaWiki_TestCase.php | 9 +++++--- 7 files changed, 40 insertions(+), 67 deletions(-) diff --git a/includes/MessageCache.php b/includes/MessageCache.php index e5eb7057eb..62f08134d2 100644 --- a/includes/MessageCache.php +++ b/includes/MessageCache.php @@ -399,16 +399,18 @@ class MessageCache { // Also delete cached sidebar... just in case it is affected global $parserMemc; - $codes = array( $code ); - if ( $code === 'en' ) { - // Delete all sidebars, like for example on action=purge on the - // sidebar messages - $codes = array_keys( Language::getLanguageNames() ); - } + if(is_object($parserMemc)) { + $codes = array( $code ); + if ( $code === 'en' ) { + // Delete all sidebars, like for example on action=purge on the + // sidebar messages + $codes = array_keys( Language::getLanguageNames() ); + } - foreach ( $codes as $code ) { - $sidebarKey = wfMemcKey( 'sidebar', $code ); - $parserMemc->delete( $sidebarKey ); + foreach ( $codes as $code ) { + $sidebarKey = wfMemcKey( 'sidebar', $code ); + $parserMemc->delete( $sidebarKey ); + } } wfRunHooks( "MessageCacheReplace", array( $title, $text ) ); diff --git a/includes/Namespace.php b/includes/Namespace.php index 974036cf69..8bf784fd95 100644 --- a/includes/Namespace.php +++ b/includes/Namespace.php @@ -8,6 +8,7 @@ * Definitions of the NS_ constants are in Defines.php * @private */ +global $wgCanonicalNamespaceNames; $wgCanonicalNamespaceNames = array( NS_MEDIA => 'Media', NS_SPECIAL => 'Special', diff --git a/includes/Title.php b/includes/Title.php index 0f2b353db2..1a301923fc 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3451,7 +3451,12 @@ class Title { * @return \type{\string} String representation of this title */ public function __toString() { - return $this->getPrefixedText(); + $bt = debug_backtrace(); + foreach($bt as $b) { + print "{$b['file']}:{$b['line']}\n"; + } + exit; + return $this->getPrefixedText(); } /** diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index a69a5c34e3..8624dc64cb 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -640,6 +640,7 @@ class ParserTest { 'wgNoFollowLinks' => true, 'wgNoFollowDomainExceptions' => array(), 'wgThumbnailScriptPath' => false, + 'wgUseImageResize' => false, 'wgUseTeX' => false, 'wgLocaltimezone' => 'UTC', 'wgAllowExternalImages' => true, diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index b00df4da86..2f9b9e0e30 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -3283,7 +3283,7 @@ Thumbnail image caption with a free URL !! input [[Image:foobar.jpg|thumb|http://example.com]] !! result -
+
!! end @@ -3292,7 +3292,7 @@ Thumbnail image caption with a free URL and explicit alt !! input [[Image:foobar.jpg|thumb|http://example.com|alt=Alteration]] !! result -
+
!! end @@ -3301,7 +3301,7 @@ BUG 1887: A ISBN with a thumbnail !! input [[Image:foobar.jpg|thumb|ISBN 1235467890]] !! result -
+
!! end @@ -3310,7 +3310,7 @@ BUG 1887: A RFC with a thumbnail !! input [[Image:foobar.jpg|thumb|This is RFC 12354]] !! result -
This is RFC 12354
+
This is RFC 12354
!! end @@ -3319,7 +3319,7 @@ BUG 1887: A mailto link with a thumbnail !! input [[Image:foobar.jpg|thumb|Please mailto:nobody@example.com]] !! result -
+
!! end @@ -3329,7 +3329,7 @@ so math is not stripped and turns up as escaped <math> tags. !! input [[Image:foobar.jpg|thumb|2+2]] !! result -
<math>2+2</math>
+
<math>2+2</math>
!! end @@ -3340,7 +3340,7 @@ math !! input [[Image:foobar.jpg|thumb|2+2]] !! result -
2 + 2
+
2 + 2
!! end @@ -3413,7 +3413,7 @@ Image caption containing another image !! input [[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]] !! result -
This is a caption with another File:Icon.png inside it!
+
This is a caption with another File:Icon.png inside it!
!! end @@ -3433,7 +3433,7 @@ Bug 3090: External links other than http: in image captions !! input [[Image:Foobar.jpg|thumb|200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]] !! result -
This caption has irc and Secure ext links in it.
+
This caption has irc and Secure ext links in it.
!! end @@ -6381,7 +6381,7 @@ Width + Height sized image (using px) (height is ignored) !! input [[Image:foobar.jpg|640x480px]] !! result -

Foobar.jpg +

Foobar.jpg

!!end @@ -6390,7 +6390,7 @@ Width-sized image (using px, no following whitespace) !! input [[Image:foobar.jpg|640px]] !! result -

Foobar.jpg +

Foobar.jpg

!!end @@ -6399,7 +6399,7 @@ Width-sized image (using px, with following whitespace - test regression from r3 !! input [[Image:foobar.jpg|640px ]] !! result -

Foobar.jpg +

Foobar.jpg

!!end @@ -6408,7 +6408,7 @@ Width-sized image (using px, with preceding whitespace - test regression from r3 !! input [[Image:foobar.jpg| 640px]] !! result -

Foobar.jpg +

Foobar.jpg

!!end @@ -6450,7 +6450,7 @@ disabled !! input [[image:Foobar.jpg|thumb|An [http://test/?param1=|left|¶m2=|x external] URL]] !! result -
An external URL
An external URL
+
An external URL
An external URL
!!end @@ -7351,7 +7351,7 @@ Free external link invading image caption !! input [[Image:Foobar.jpg|thumb|http://x|hello]] !! result -
hello
+
hello
!! end diff --git a/tests/MediaWikiParserTest.php b/tests/MediaWikiParserTest.php index ad2ed61e0e..600ed34d7e 100644 --- a/tests/MediaWikiParserTest.php +++ b/tests/MediaWikiParserTest.php @@ -23,7 +23,6 @@ class PTShell extends ParserTest { function showSuccess( $desc ) { $this->cb->assertTrue( true, $desc ); - echo "PASSED: $desc\n"; return true; } @@ -146,21 +145,10 @@ class MediaWikiParserTest extends PHPUnit_Framework_TestCase { $wgStyleSheetPath = '/skins'; $wgStylePath = '/skins'; $wgThumbnailScriptPath = false; - $this->uploadDir = $this->setupUploadDir(); - $wgLocalFileRepo = array( - 'class' => 'LocalRepo', - 'name' => 'local', - 'directory' => $this->uploadDir, - 'url' => 'http://example.com/images', - 'hashLevels' => 2, - 'transformVia404' => false, - ); - //$wgNamespacesWithSubpages = array( 0 => isset( $opts['subpage'] ) ); $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface'; $wgNamespaceAliases['Image'] = NS_FILE; $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK; - $wgEnableParserCache = false; $wgDeferredUpdateList = array(); $wgMemc =& wfGetMainCache(); @@ -181,35 +169,8 @@ class MediaWikiParserTest extends PHPUnit_Framework_TestCase { $this->parserTester = new PTShell(); $this->parserTester->setCallback( $this ); - /* global $wgDBtype, $wgDBserver, $wgDBname, $wgDBuser, $wgDBpassword, $wgDBport, $wgDBmwschema, $wgDBts2chema; */ - /* $this->db['type'] = $wgDBtype; */ - /* $this->db['server'] = $wgDBserver; */ - /* $this->db['name'] = $wgDBname; */ - /* $this->db['user'] = $wgDBuser; */ - /* $this->db['password'] = $wgDBpassword; */ - /* $this->db['port'] = $wgDBport; */ - /* $this->db['mwschema'] = $wgDBmwschema; */ - /* $this->db['ts2schema'] = $wgDBts2chema; */ - } - - function tearDown() { - $this->teardownUploadDir($this->uploadDir); - /* $db = wfGetDB( DB_MASTER ); */ - /* $db->close(); */ - /* global $wgDBtype, $wgDBserver, $wgDBname, $wgDBuser, $wgDBpassword, $wgDBport, $wgDBmwschema, $wgDBts2chema; */ - - /* $wgDBtype = $this->db['type']; */ - /* $wgDBserver = $this->db['server']; */ - /* $wgDBname = $this->db['name']; */ - /* $wgDBuser = $this->db['user']; */ - /* $wgDBpassword = $this->db['password']; */ - /* $wgDBport = $this->db['port']; */ - /* $wgDBmwschema = $this->db['mwschema']; */ - /* $wgDBts2chema = $this->db['ts2schema']; */ - } - function testParser() { global $IP; diff --git a/tests/MediaWiki_TestCase.php b/tests/MediaWiki_TestCase.php index 3e6b40acdf..5ddb93a5fd 100644 --- a/tests/MediaWiki_TestCase.php +++ b/tests/MediaWiki_TestCase.php @@ -7,7 +7,10 @@ abstract class MediaWiki_TestCase extends PHPUnit_Framework_TestCase { */ protected function buildTestDatabase( $tables ) { global $testOptions, $wgDBprefix, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname; - $this->markTestIncomplete("This test requires DB admin user credentials."); + if(!$wgDBadminuser || !$wgDBadminpassword) { + $this->markTestIncomplete("This test requires DB admin user credentials."); + } + $wgDBprefix = 'parsertest_'; $db = new DatabaseMysql( @@ -16,7 +19,8 @@ abstract class MediaWiki_TestCase extends PHPUnit_Framework_TestCase { $wgDBadminpassword, $wgDBname ); if( $db->isOpen() ) { - if (!(strcmp($db->getServerVersion(), '4.1') < 0 and stristr($db->getSoftwareLink(), 'MySQL'))) { + if (!(strcmp($db->getServerVersion(), '4.1') < 0 and + stristr($db->getSoftwareLink(), 'MySQL'))) { # Database that supports CREATE TABLE ... LIKE foreach ($tables as $tbl) { $newTableName = $db->tableName( $tbl ); @@ -41,7 +45,6 @@ abstract class MediaWiki_TestCase extends PHPUnit_Framework_TestCase { } $db->query($create_tmp); } - } return $db; } else { -- 2.20.1