r70916 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70915‎ | r70916 | r70917 >
Date:21:22, 11 August 2010
Author:platonides
Status:deferred (Comments)
Tags:
Comment:
Made tests more independent. Some items were only working before previous ones left in the appropiate state, or because the installation language was English.
Modified paths:
  • /trunk/phase3/maintenance/tests/ApiWatchTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/ExtraParserTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/LanguageConverterTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/MessageTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/SearchDbTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/SearchUpdateTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/TitlePermissionTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/UploadTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/ApiWatchTest.php
@@ -6,8 +6,18 @@
77 ini_set( 'log_errors', 1 );
88 ini_set( 'error_reporting', 1 );
99 ini_set( 'display_errors', 1 );
 10+
 11+ global $wgMemc;
 12+ $wgMemc = new FakeMemCachedClient;
1013 }
1114
 15+ function tearDown() {
 16+ global $wgMemc;
 17+
 18+ $wgMemc = null;
 19+ }
 20+
 21+
1222 function doApiRequest( $params, $data = null ) {
1323 $_SESSION = isset( $data[2] ) ? $data[2] : array();
1424
Index: trunk/phase3/maintenance/tests/ExtraParserTest.php
@@ -3,8 +3,20 @@
44 * Parser-related tests that don't suit for parserTests.txt
55 */
66
7 - class ExtraParserTest extends PHPUnit_Framework_TestCase {
 7+class ExtraParserTest extends PHPUnit_Framework_TestCase {
88
 9+ function setUp() {
 10+ global $wgMemc;
 11+
 12+ $wgMemc = new FakeMemCachedClient;
 13+ }
 14+
 15+ function tearDown() {
 16+ global $wgMemc;
 17+
 18+ $wgMemc = null;
 19+ }
 20+
921 // Bug 8689 - Long numeric lines kill the parser
1022 function testBug8689() {
1123 $longLine = '1.' . str_repeat( '1234567890', 100000 ) . "\n";
@@ -15,4 +27,4 @@
1628 $this->assertEquals( "<p>$longLine</p>",
1729 $parser->parse( $longLine, $t, $options )->getText() );
1830 }
19 - }
\ No newline at end of file
 31+ }
Index: trunk/phase3/maintenance/tests/SearchDbTest.php
@@ -24,6 +24,7 @@
2525 }
2626 unset( $this->db );
2727 unset( $this->search );
 28+ $GLOBALS['wgContLang'] = null;
2829 }
2930 }
3031
Index: trunk/phase3/maintenance/tests/LanguageConverterTest.php
@@ -17,10 +17,11 @@
1818 }
1919
2020 function tearDown() {
21 - global $wgMemc;
 21+ global $wgMemc, $wgContLang;
2222 unset( $wgMemc );
2323 unset( $this->lc );
2424 unset( $this->lang );
 25+ $wgContLang = null;
2526 }
2627
2728 function testGetPreferredVariantDefaults() {
Index: trunk/phase3/maintenance/tests/UploadTest.php
@@ -7,7 +7,9 @@
88
99
1010 function setUp() {
 11+ global $wgContLang;
1112 parent::setup();
 13+ $wgContLang = Language::factory( 'en' );
1214 $this->upload = new UploadTestHandler;
1315 }
1416
Index: trunk/phase3/maintenance/tests/MessageTest.php
@@ -1,6 +1,13 @@
22 <?php
33
44 class MessageTest extends PHPUnit_Framework_TestCase {
 5+
 6+ function setUp() {
 7+ global $wgContLanguageCode;
 8+
 9+ $wgContLanguageCode = 'en'; # For mainpage to be 'Main Page'
 10+ }
 11+
512 function testExists() {
613 $this->assertTrue( Message::key( 'mainpage' )->exists() );
714 $this->assertTrue( Message::key( 'mainpage' )->params( array() )->exists() );
@@ -30,4 +37,4 @@
3138 function testInLanguageThrows() {
3239 Message::key( 'foo' )->inLanguage( 123 );
3340 }
34 -}
\ No newline at end of file
 41+}
Index: trunk/phase3/maintenance/tests/TitlePermissionTest.php
@@ -10,7 +10,12 @@
1111 static $altUserName;
1212
1313 function setUp() {
14 - global $wgLocaltimezone, $wgLocalTZoffset;
 14+ global $wgLocaltimezone, $wgLocalTZoffset, $wgMemc, $wgContLang, $wgLang, $wgMessageCache;
 15+
 16+ $wgMemc = new FakeMemCachedClient;
 17+ $wgMessageCache = new MessageCache( $wgMemc, true, 3600 );
 18+ $wgContLang = $wgLang = Language::factory( 'en' );
 19+
1520 self::$userName = "Useruser";
1621 self::$altUserName = "Altuseruser";
1722 date_default_timezone_set( $wgLocaltimezone );
@@ -39,6 +44,11 @@
4045 }
4146 }
4247
 48+ function tearDown() {
 49+ global $wgMemc, $wgContLang, $wgLang;
 50+ $wgMemc = $wgContLang = $wgLang = null;
 51+ }
 52+
4353 function setUserPerm( $perm ) {
4454 if ( is_array( $perm ) ) {
4555 self::$user->mRights = $perm;
@@ -638,4 +648,4 @@
639649 # $user->blockedFor() == ''
640650 # $user->mBlock->mExpiry == 'infinity'
641651 }
642 -}
\ No newline at end of file
 652+}
Index: trunk/phase3/maintenance/tests/SearchUpdateTest.php
@@ -62,7 +62,7 @@
6363 }
6464
6565 function setUp() {
66 - global $wgSearchType, $wgDBtype, $wgLBFactoryConf, $wgDBservers;
 66+ global $wgSearchType, $wgDBtype, $wgLBFactoryConf, $wgDBservers, $wgContLang;
6767
6868 self::$searchType = $wgSearchType;
6969 self::$dbtype = $wgDBtype;
@@ -73,6 +73,7 @@
7474 $wgDBtype = 'mock';
7575 $wgLBFactoryConf['class'] = 'LBFactory_Simple';
7676 $wgDBservers = null;
 77+ $wgContLang = Language::factory( 'en' );
7778 LBFactory::destroyInstance();
7879 }
7980
@@ -85,6 +86,7 @@
8687 $wgDBtype = self::$dbtype;
8788 $wgLBFactoryConf = self::$factoryconf;
8889 $wgDBservers = self::$dbservers;
 90+ $wgContLang = null;
8991 }
9092
9193 function testUpdateText() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r70955Follow up r70916. Missing global.platonides14:02, 12 August 2010
r75224re r70916: avoid resetting $wgMemc which leads to failures for memah03:01, 23 October 2010

Comments

#Comment by Simetrical (talk | contribs)   19:40, 12 August 2010

I'm getting tons of failures after this commit. I've pastebinned them: http://pastebin.com/KFhTxkUD

#Comment by Simetrical (talk | contribs)   23:05, 12 August 2010

Oops, wrong commit. I meant r70917.

#Comment by MarkAHershberger (talk | contribs)   02:25, 23 October 2010

+ $wgMemc = new FakeMemCachedClient;

I had to make this conditional and remove "$wgMemc =" from

+ $wgMemc = $wgContLang = $wgLang = null;

so that it only happens when $wgMemc is not defined or I would get failures.

#Comment by Platonides (talk | contribs)   17:39, 25 October 2010

$wgMemc = null; could break further tests, but I don't see how setting $wgMemc to a FakeMemCachedClient would break anything (other than havin no caching, of course).

Status & tagging log