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
-.PHONY: help test phpunit install coverage warning destructive parser noparser list-groups
+.PHONY: help test phpunit install coverage warning destructive parser noparser safe databaseless list-groups
.DEFAULT: warning
SHELL = /bin/sh
warning:
# Use 'make help' to get usage
- @echo "WARNING -- these tests are DESTRUCTIVE and will alter your wiki."
+ @echo "WARNING -- some tests are DESTRUCTIVE and will alter your wiki."
@echo "DO NOT RUN THESE TESTS on a production wiki."
@echo ""
@echo "Until the default suites are made non-destructive, you can run"
@echo "the destructive tests like so:"
- @echo ""
@echo " make destructive"
@echo ""
+ @echo "Some tests are expected to be safe, you can run them with"
+ @echo " make safe"
+ @echo ""
+ @echo "You are recommended to run them with read-only credentials, though."
+ @echo ""
+ @echo "If you don't have a database running, you can still run"
+ @echo " make databaseless"
+ @echo ""
destructive: phpunit
noparser:
${PU} --exclude-group Parser,Broken
+safe:
+ ${PU} --exclude-group Broken,Destructive
+
+databaseless:
+ ${PU} --exclude-group Broken,Destructive,Database
+
list-groups:
${PU} --list-groups
EOF;
}
+global $wgLocalisationCacheConf, $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType;
+global $wgMessageCache, $messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry;
+$wgLocalisationCacheConf['storeClass'] = 'LCStore_Null';
+$wgMainCacheType = CACHE_NONE;
+$wgMessageCacheType = CACHE_NONE;
+$wgParserCacheType = CACHE_NONE;
+$wgUseDatabaseMessages = false; # Set for future resets
+
+# The message cache was already created in Setup.php
+$wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache',
+ array( $messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry ) );
+
/* Classes */
abstract class MediaWikiTestSetup extends PHPUnit_Framework_TestCase {
$wgUser = new User;
$wgUser->setId( 1 );
$wgUser->mDataLoaded = true;
+ $wgUser->mOptionsLoaded = true;
$wgUser->setOption( 'variant', 'tg-latn' );
$this->assertEquals( 'tg-latn', $this->lc->getPreferredVariant() );
$wgRequest->setVal( 'variant', 'tg' );
$wgUser = User::newFromId( "admin" );
$wgUser->setId( 1 );
+ $wgUser->mDataLoaded = true;
+ $wgUser->mOptionsLoaded = true;
$wgUser->setOption( 'variant', 'tg-latn' ); // The user's data is ignored
// because the variant is set in the URL.
$this->assertEquals( 'tg', $this->lc->getPreferredVariant() );
$wgLanguageCode = 'en'; # For mainpage to be 'Main Page'
//Note that a Stub Object is not enough for this test
$wgContLang = $wgLang = Language::factory( $wgLanguageCode );
- $wgMessageCache = new MessageCache( false, true, 3600 );
+ $wgMessageCache = new MessageCache( false, false, 3600 );
}
function testExists() {
<?php
+/**
+ * @group Database
+ * @group Destructive
+ */
class TitlePermissionTest extends PHPUnit_Framework_TestCase {
static $title;
static $user;
}
/**
+ * @group Database
* @group Destructive
*/
class ApiTest extends ApiTestSetup {
require_once dirname( __FILE__ ) . '/ApiSetup.php';
/**
+ * @group Database
* @group Destructive
*/
class ApiWatchTest extends ApiTestSetup {
<?php
+/**
+ * @group Database
+ */
class DatabaseTest extends PHPUnit_Framework_TestCase {
var $db;
require_once( dirname( __FILE__ ) . '/SearchEngineTest.php' );
+/**
+ * @group Database
+ * @group Destructive
+ */
class SearchDbTest extends SearchEngineTest {
var $db;
/**
* This class is not directly tested. Instead it is extended by SearchDbTest.
* @group Stub
+ * @group Destructive
*/
class SearchEngineTest extends MediaWikiTestSetup {
var $db, $search, $pageList;
$wgDBtype = 'mock';
$wgLBFactoryConf['class'] = 'LBFactory_Simple';
$wgDBservers = null;
+
+ # We need to reset the LoadBalancer in order to bypass its cache and get the mock db
+ wfGetLBFactory()->destroyInstance();
$wgContLang = Language::factory( 'en' );
}