Index: trunk/phase3/maintenance/tests/phpunit/bootstrap.php |
— | — | @@ -28,6 +28,18 @@ |
29 | 29 | EOF; |
30 | 30 | } |
31 | 31 | |
| 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 | + |
32 | 44 | /* Classes */ |
33 | 45 | |
34 | 46 | abstract class MediaWikiTestSetup extends PHPUnit_Framework_TestCase { |
Index: trunk/phase3/maintenance/tests/phpunit/includes/TitlePermissionTest.php |
— | — | @@ -1,5 +1,9 @@ |
2 | 2 | <?php |
3 | 3 | |
| 4 | +/** |
| 5 | + * @group Database |
| 6 | + * @group Destructive |
| 7 | + */ |
4 | 8 | class TitlePermissionTest extends PHPUnit_Framework_TestCase { |
5 | 9 | static $title; |
6 | 10 | static $user; |
Index: trunk/phase3/maintenance/tests/phpunit/includes/db/DatabaseTest.php |
— | — | @@ -1,5 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | |
| 4 | +/** |
| 5 | + * @group Database |
| 6 | + */ |
4 | 7 | class DatabaseTest extends PHPUnit_Framework_TestCase { |
5 | 8 | var $db; |
6 | 9 | |
Index: trunk/phase3/maintenance/tests/phpunit/includes/LanguageConverterTest.php |
— | — | @@ -62,6 +62,7 @@ |
63 | 63 | $wgUser = new User; |
64 | 64 | $wgUser->setId( 1 ); |
65 | 65 | $wgUser->mDataLoaded = true; |
| 66 | + $wgUser->mOptionsLoaded = true; |
66 | 67 | $wgUser->setOption( 'variant', 'tg-latn' ); |
67 | 68 | |
68 | 69 | $this->assertEquals( 'tg-latn', $this->lc->getPreferredVariant() ); |
— | — | @@ -74,6 +75,8 @@ |
75 | 76 | $wgRequest->setVal( 'variant', 'tg' ); |
76 | 77 | $wgUser = User::newFromId( "admin" ); |
77 | 78 | $wgUser->setId( 1 ); |
| 79 | + $wgUser->mDataLoaded = true; |
| 80 | + $wgUser->mOptionsLoaded = true; |
78 | 81 | $wgUser->setOption( 'variant', 'tg-latn' ); // The user's data is ignored |
79 | 82 | // because the variant is set in the URL. |
80 | 83 | $this->assertEquals( 'tg', $this->lc->getPreferredVariant() ); |
Index: trunk/phase3/maintenance/tests/phpunit/includes/search/SearchDbTest.php |
— | — | @@ -2,6 +2,10 @@ |
3 | 3 | |
4 | 4 | require_once( dirname( __FILE__ ) . '/SearchEngineTest.php' ); |
5 | 5 | |
| 6 | +/** |
| 7 | + * @group Database |
| 8 | + * @group Destructive |
| 9 | + */ |
6 | 10 | class SearchDbTest extends SearchEngineTest { |
7 | 11 | var $db; |
8 | 12 | |
Index: trunk/phase3/maintenance/tests/phpunit/includes/search/SearchEngineTest.php |
— | — | @@ -5,6 +5,7 @@ |
6 | 6 | /** |
7 | 7 | * This class is not directly tested. Instead it is extended by SearchDbTest. |
8 | 8 | * @group Stub |
| 9 | + * @group Destructive |
9 | 10 | */ |
10 | 11 | class SearchEngineTest extends MediaWikiTestSetup { |
11 | 12 | var $db, $search, $pageList; |
Index: trunk/phase3/maintenance/tests/phpunit/includes/search/SearchUpdateTest.php |
— | — | @@ -73,6 +73,9 @@ |
74 | 74 | $wgDBtype = 'mock'; |
75 | 75 | $wgLBFactoryConf['class'] = 'LBFactory_Simple'; |
76 | 76 | $wgDBservers = null; |
| 77 | + |
| 78 | + # We need to reset the LoadBalancer in order to bypass its cache and get the mock db |
| 79 | + wfGetLBFactory()->destroyInstance(); |
77 | 80 | $wgContLang = Language::factory( 'en' ); |
78 | 81 | } |
79 | 82 | |
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
| 22 | + * @group Database |
22 | 23 | * @group Destructive |
23 | 24 | */ |
24 | 25 | class ApiTest extends ApiTestSetup { |
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiWatchTest.php |
— | — | @@ -3,6 +3,7 @@ |
4 | 4 | require_once dirname( __FILE__ ) . '/ApiSetup.php'; |
5 | 5 | |
6 | 6 | /** |
| 7 | + * @group Database |
7 | 8 | * @group Destructive |
8 | 9 | */ |
9 | 10 | class ApiWatchTest extends ApiTestSetup { |
Index: trunk/phase3/maintenance/tests/phpunit/includes/MessageTest.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | $wgLanguageCode = 'en'; # For mainpage to be 'Main Page' |
10 | 10 | //Note that a Stub Object is not enough for this test |
11 | 11 | $wgContLang = $wgLang = Language::factory( $wgLanguageCode ); |
12 | | - $wgMessageCache = new MessageCache( false, true, 3600 ); |
| 12 | + $wgMessageCache = new MessageCache( false, false, 3600 ); |
13 | 13 | } |
14 | 14 | |
15 | 15 | 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 |
3 | 3 | .DEFAULT: warning |
4 | 4 | |
5 | 5 | SHELL = /bin/sh |
— | — | @@ -10,14 +10,21 @@ |
11 | 11 | |
12 | 12 | warning: |
13 | 13 | # 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." |
15 | 15 | @echo "DO NOT RUN THESE TESTS on a production wiki." |
16 | 16 | @echo "" |
17 | 17 | @echo "Until the default suites are made non-destructive, you can run" |
18 | 18 | @echo "the destructive tests like so:" |
19 | | - @echo "" |
20 | 19 | @echo " make destructive" |
21 | 20 | @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 "" |
22 | 29 | |
23 | 30 | destructive: phpunit |
24 | 31 | |
— | — | @@ -39,6 +46,12 @@ |
40 | 47 | noparser: |
41 | 48 | ${PU} --exclude-group Parser,Broken |
42 | 49 | |
| 50 | +safe: |
| 51 | + ${PU} --exclude-group Broken,Destructive |
| 52 | + |
| 53 | +databaseless: |
| 54 | + ${PU} --exclude-group Broken,Destructive,Database |
| 55 | + |
43 | 56 | list-groups: |
44 | 57 | ${PU} --list-groups |
45 | 58 | |