r75810 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75809‎ | r75810 | r75811 >
Date:18:23, 1 November 2010
Author:platonides
Status:deferred
Tags:
Comment:
Modified the tests so that a database is not unnecessarily required.

Database group for tests needing a db. The other tests should be runnable without a server running!
Destructive group for tests which modify the db.

Added two more actions to the makefile: safe and databaseless
Modified paths:
  • /trunk/phase3/maintenance/tests/phpunit/Makefile (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/bootstrap.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/LanguageConverterTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/MessageTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/TitlePermissionTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/api/ApiWatchTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/db/DatabaseTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/search/SearchDbTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/search/SearchEngineTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/search/SearchUpdateTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/bootstrap.php
@@ -28,6 +28,18 @@
2929 EOF;
3030 }
3131
 32+global $wgLocalisationCacheConf, $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType;
 33+global $wgMessageCache, $messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry;
 34+$wgLocalisationCacheConf['storeClass'] = 'LCStore_Null';
 35+$wgMainCacheType = CACHE_NONE;
 36+$wgMessageCacheType = CACHE_NONE;
 37+$wgParserCacheType = CACHE_NONE;
 38+$wgUseDatabaseMessages = false; # Set for future resets
 39+
 40+# The message cache was already created in Setup.php
 41+$wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache',
 42+ array( $messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry ) );
 43+
3244 /* Classes */
3345
3446 abstract class MediaWikiTestSetup extends PHPUnit_Framework_TestCase {
Index: trunk/phase3/maintenance/tests/phpunit/includes/TitlePermissionTest.php
@@ -1,5 +1,9 @@
22 <?php
33
 4+/**
 5+ * @group Database
 6+ * @group Destructive
 7+ */
48 class TitlePermissionTest extends PHPUnit_Framework_TestCase {
59 static $title;
610 static $user;
Index: trunk/phase3/maintenance/tests/phpunit/includes/db/DatabaseTest.php
@@ -1,5 +1,8 @@
22 <?php
33
 4+/**
 5+ * @group Database
 6+ */
47 class DatabaseTest extends PHPUnit_Framework_TestCase {
58 var $db;
69
Index: trunk/phase3/maintenance/tests/phpunit/includes/LanguageConverterTest.php
@@ -62,6 +62,7 @@
6363 $wgUser = new User;
6464 $wgUser->setId( 1 );
6565 $wgUser->mDataLoaded = true;
 66+ $wgUser->mOptionsLoaded = true;
6667 $wgUser->setOption( 'variant', 'tg-latn' );
6768
6869 $this->assertEquals( 'tg-latn', $this->lc->getPreferredVariant() );
@@ -74,6 +75,8 @@
7576 $wgRequest->setVal( 'variant', 'tg' );
7677 $wgUser = User::newFromId( "admin" );
7778 $wgUser->setId( 1 );
 79+ $wgUser->mDataLoaded = true;
 80+ $wgUser->mOptionsLoaded = true;
7881 $wgUser->setOption( 'variant', 'tg-latn' ); // The user's data is ignored
7982 // because the variant is set in the URL.
8083 $this->assertEquals( 'tg', $this->lc->getPreferredVariant() );
Index: trunk/phase3/maintenance/tests/phpunit/includes/search/SearchDbTest.php
@@ -2,6 +2,10 @@
33
44 require_once( dirname( __FILE__ ) . '/SearchEngineTest.php' );
55
 6+/**
 7+ * @group Database
 8+ * @group Destructive
 9+ */
610 class SearchDbTest extends SearchEngineTest {
711 var $db;
812
Index: trunk/phase3/maintenance/tests/phpunit/includes/search/SearchEngineTest.php
@@ -5,6 +5,7 @@
66 /**
77 * This class is not directly tested. Instead it is extended by SearchDbTest.
88 * @group Stub
 9+ * @group Destructive
910 */
1011 class SearchEngineTest extends MediaWikiTestSetup {
1112 var $db, $search, $pageList;
Index: trunk/phase3/maintenance/tests/phpunit/includes/search/SearchUpdateTest.php
@@ -73,6 +73,9 @@
7474 $wgDBtype = 'mock';
7575 $wgLBFactoryConf['class'] = 'LBFactory_Simple';
7676 $wgDBservers = null;
 77+
 78+ # We need to reset the LoadBalancer in order to bypass its cache and get the mock db
 79+ wfGetLBFactory()->destroyInstance();
7780 $wgContLang = Language::factory( 'en' );
7881 }
7982
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php
@@ -18,6 +18,7 @@
1919 }
2020
2121 /**
 22+ * @group Database
2223 * @group Destructive
2324 */
2425 class ApiTest extends ApiTestSetup {
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiWatchTest.php
@@ -3,6 +3,7 @@
44 require_once dirname( __FILE__ ) . '/ApiSetup.php';
55
66 /**
 7+ * @group Database
78 * @group Destructive
89 */
910 class ApiWatchTest extends ApiTestSetup {
Index: trunk/phase3/maintenance/tests/phpunit/includes/MessageTest.php
@@ -8,7 +8,7 @@
99 $wgLanguageCode = 'en'; # For mainpage to be 'Main Page'
1010 //Note that a Stub Object is not enough for this test
1111 $wgContLang = $wgLang = Language::factory( $wgLanguageCode );
12 - $wgMessageCache = new MessageCache( false, true, 3600 );
 12+ $wgMessageCache = new MessageCache( false, false, 3600 );
1313 }
1414
1515 function testExists() {
Index: trunk/phase3/maintenance/tests/phpunit/Makefile
@@ -1,4 +1,4 @@
2 -.PHONY: help test phpunit install coverage warning destructive parser noparser list-groups
 2+.PHONY: help test phpunit install coverage warning destructive parser noparser safe databaseless list-groups
33 .DEFAULT: warning
44
55 SHELL = /bin/sh
@@ -10,14 +10,21 @@
1111
1212 warning:
1313 # Use 'make help' to get usage
14 - @echo "WARNING -- these tests are DESTRUCTIVE and will alter your wiki."
 14+ @echo "WARNING -- some tests are DESTRUCTIVE and will alter your wiki."
1515 @echo "DO NOT RUN THESE TESTS on a production wiki."
1616 @echo ""
1717 @echo "Until the default suites are made non-destructive, you can run"
1818 @echo "the destructive tests like so:"
19 - @echo ""
2019 @echo " make destructive"
2120 @echo ""
 21+ @echo "Some tests are expected to be safe, you can run them with"
 22+ @echo " make safe"
 23+ @echo ""
 24+ @echo "You are recommended to run them with read-only credentials, though."
 25+ @echo ""
 26+ @echo "If you don't have a database running, you can still run"
 27+ @echo " make databaseless"
 28+ @echo ""
2229
2330 destructive: phpunit
2431
@@ -39,6 +46,12 @@
4047 noparser:
4148 ${PU} --exclude-group Parser,Broken
4249
 50+safe:
 51+ ${PU} --exclude-group Broken,Destructive
 52+
 53+databaseless:
 54+ ${PU} --exclude-group Broken,Destructive,Database
 55+
4356 list-groups:
4457 ${PU} --list-groups
4558

Follow-up revisions

RevisionCommit summaryAuthorDate
r76134Follow up r75810. The code for the parser tests modified the main database ev...platonides20:03, 5 November 2010

Status & tagging log