MediaWiki  1.23.8

Sets a global, maintaining a stashed version of the previous global to be restored in tearDownThe key is added to the array of globals that will be reset afterwards in the tearDown().

protected function setUp() { $this->setMwGlobals( 'wgRestrictStuff', true ); }

function testFoo() {}

function testBar() {} $this->assertTrue( self::getX()->doStuff() );

$this->setMwGlobals( 'wgRestrictStuff', false ); $this->assertTrue( self::getX()->doStuff() ); }

function testQuux() {}

array | string$pairsKey to the global variable, or an array of key/value pairs.
mixed$valueValue to set the global to (ignored if an array is given as first argument).
abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
private $called = array();
public static $users;
protected $db;
protected $tablesUsed = array(); // tables with data
private static $useTemporaryTables = true;
private static $reuseDB = false;
private static $dbSetup = false;
private static $oldTablePrefix = false;
private $phpErrorLevel;
private $tmpFiles = array();
private $mwGlobals = array();
const DB_PREFIX = 'unittest_';
const ORA_DB_PREFIX = 'ut_';
protected $supportedDBs = array(
public function __construct( $name = null, array $data = array(), $dataName = '' ) {
parent::__construct( $name, $data, $dataName );
$this->backupGlobals = false;
$this->backupStaticAttributes = false;
public function run( PHPUnit_Framework_TestResult $result = null ) {
/* Some functions require some kind of caching, and will end up using the db,
* which we can't allow, as that would open a new connection for mysql.
* Replace with a HashBag. They would not be going to persist anyway.
$needsResetDB = false;
$logName = get_class( $this ) . '::' . $this->getName( false );
if ( $this->needsDB() ) {
// set up a DB connection for this test to use
self::$useTemporaryTables = !$this->getCliArg( 'use-normal-tables' );
self::$reuseDB = $this->getCliArg( 'reuse-db' );
$this->db = wfGetDB( DB_MASTER );
if ( !self::$dbSetup ) {
wfProfileIn( $logName . ' (clone-db)' );
// switch to a temporary clone of the database
self::setupTestDB( $this->db, $this->dbPrefix() );
if ( ( $this->db->getType() == 'oracle' || !self::$useTemporaryTables ) && self::$reuseDB ) {
wfProfileOut( $logName . ' (clone-db)' );
wfProfileIn( $logName . ' (prepare-db)' );
wfProfileOut( $logName . ' (prepare-db)' );
$needsResetDB = true;
wfProfileIn( $logName );
parent::run( $result );
wfProfileOut( $logName );
if ( $needsResetDB ) {
wfProfileIn( $logName . ' (reset-db)' );
wfProfileOut( $logName . ' (reset-db)' );
public function usesTemporaryTables() {
protected function getNewTempFile() {
$fileName = tempnam( wfTempDir(), 'MW_PHPUnit_' . get_class( $this ) . '_' );
$this->tmpFiles[] = $fileName;
return $fileName;
protected function getNewTempDirectory() {
// Starting of with a temporary /file/.
$fileName = $this->getNewTempFile();
// Converting the temporary /file/ to a /directory/
// The following is not atomic, but at least we now have a single place,
// where temporary directory creation is bundled and can be improved
unlink( $fileName );
$this->assertTrue( wfMkdirParents( $fileName ) );
return $fileName;
protected function setUp() {
wfProfileIn( __METHOD__ );
$this->called['setUp'] = 1;
$this->phpErrorLevel = intval( ini_get( 'error_reporting' ) );
// Cleaning up temporary files
foreach ( $this->tmpFiles as $fileName ) {
if ( is_file( $fileName ) || ( is_link( $fileName ) ) ) {
unlink( $fileName );
} elseif ( is_dir( $fileName ) ) {
wfRecursiveRemoveDir( $fileName );
if ( $this->needsDB() && $this->db ) {
// Clean up open transactions
while ( $this->db->trxLevel() > 0 ) {
// don't ignore DB errors
$this->db->ignoreErrors( false );
wfProfileOut( __METHOD__ );
protected function tearDown() {
wfProfileIn( __METHOD__ );
// Cleaning up temporary files
foreach ( $this->tmpFiles as $fileName ) {
if ( is_file( $fileName ) || ( is_link( $fileName ) ) ) {
unlink( $fileName );
} elseif ( is_dir( $fileName ) ) {
wfRecursiveRemoveDir( $fileName );
if ( $this->needsDB() && $this->db ) {
// Clean up open transactions
while ( $this->db->trxLevel() > 0 ) {
// don't ignore DB errors
$this->db->ignoreErrors( false );
// Restore mw globals
foreach ( $this->mwGlobals as $key => $value ) {
$GLOBALS[$key] = $value;
$this->mwGlobals = array();
$phpErrorLevel = intval( ini_get( 'error_reporting' ) );
if ( $phpErrorLevel !== $this->phpErrorLevel ) {
ini_set( 'error_reporting', $this->phpErrorLevel );
$oldHex = strtoupper( dechex( $this->phpErrorLevel ) );
$newHex = strtoupper( dechex( $phpErrorLevel ) );
$message = "PHP error_reporting setting was left dirty: was 0x$oldHex before test, 0x$newHex after test!";
$this->fail( $message );
wfProfileOut( __METHOD__ );
final public function testMediaWikiTestCaseParentSetupCalled() {
$this->assertArrayHasKey( 'setUp', $this->called,
get_called_class() . "::setUp() must call parent::setUp()"
protected function setMwGlobals( $pairs, $value = null ) {
if ( is_string( $pairs ) ) {
$pairs = array( $pairs => $value );
$this->stashMwGlobals( array_keys( $pairs ) );
foreach ( $pairs as $key => $value ) {
$GLOBALS[$key] = $value;
protected function stashMwGlobals( $globalKeys ) {
if ( is_string( $globalKeys ) ) {
$globalKeys = array( $globalKeys );
foreach ( $globalKeys as $globalKey ) {
// NOTE: make sure we only save the global once or a second call to
// setMwGlobals() on the same global would override the original
// value.
if ( !array_key_exists( $globalKey, $this->mwGlobals ) ) {
if ( !array_key_exists( $globalKey, $GLOBALS ) ) {
throw new Exception( "Global with key {$globalKey} doesn't exist and cant be stashed" );
// NOTE: we serialize then unserialize the value in case it is an object
// this stops any objects being passed by reference. We could use clone
// and if is_object but this does account for objects within objects!
try {
$this->mwGlobals[$globalKey] = unserialize( serialize( $GLOBALS[$globalKey] ) );
// NOTE; some things such as Closures are not serializable
// in this case just set the value!
catch ( Exception $e ) {
$this->mwGlobals[$globalKey] = $GLOBALS[$globalKey];
protected function mergeMwGlobalArrayValue( $name, $values ) {
if ( !isset( $GLOBALS[$name] ) ) {
$merged = $values;
} else {
if ( !is_array( $GLOBALS[$name] ) ) {
throw new MWException( "MW global $name is not an array." );
// NOTE: do not use array_merge, it screws up for numeric keys.
$merged = $GLOBALS[$name];
foreach ( $values as $k => $v ) {
$merged[$k] = $v;
$this->setMwGlobals( $name, $merged );
public function dbPrefix() {
return $this->db->getType() == 'oracle' ? self::ORA_DB_PREFIX : self::DB_PREFIX;
public function needsDB() {
# if the test says it uses database tables, it needs the database
if ( $this->tablesUsed ) {
return true;
# if the test says it belongs to the Database group, it needs the database
$rc = new ReflectionClass( $this );
if ( preg_match( '/@group +Database/im', $rc->getDocComment() ) ) {
return true;
return false;
public function addDBData() {
private function addCoreDBData() {
if ( $this->db->getType() == 'oracle' ) {
# Insert 0 user to prevent FK violations
# Anonymous user
$this->db->insert( 'user', array(
'user_id' => 0,
'user_name' => 'Anonymous' ), __METHOD__, array( 'IGNORE' ) );
# Insert 0 page to prevent FK violations
# Blank page
$this->db->insert( 'page', array(
'page_id' => 0,
'page_namespace' => 0,
'page_title' => ' ',
'page_restrictions' => null,
'page_counter' => 0,
'page_is_redirect' => 0,
'page_is_new' => 0,
'page_random' => 0,
'page_touched' => $this->db->timestamp(),
'page_latest' => 0,
'page_len' => 0 ), __METHOD__, array( 'IGNORE' ) );
//Make sysop user
$user = User::newFromName( 'UTSysop' );
if ( $user->idForName() == 0 ) {
$user->setPassword( 'UTSysopPassword' );
$user->addGroup( 'sysop' );
$user->addGroup( 'bureaucrat' );
//Make 1 page with 1 revision
$page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
if ( !$page->getId() == 0 ) {
new WikitextContent( 'UTContent' ),
User::newFromName( 'UTSysop' ) );
public static function teardownTestDB() {
if ( !self::$dbSetup ) {
CloneDatabase::changePrefix( self::$oldTablePrefix );
self::$oldTablePrefix = false;
self::$dbSetup = false;
public static function setupTestDB( DatabaseBase $db, $prefix ) {
global $wgDBprefix;
if ( $wgDBprefix === $prefix ) {
throw new MWException(
'Cannot run unit tests, the database prefix is already "' . $prefix . '"' );
if ( self::$dbSetup ) {
$tablesCloned = self::listTables( $db );
$dbClone = new CloneDatabase( $db, $tablesCloned, $prefix );
$dbClone->useTemporaryTables( self::$useTemporaryTables );
self::$dbSetup = true;
self::$oldTablePrefix = $wgDBprefix;
if ( ( $db->getType() == 'oracle' || !self::$useTemporaryTables ) && self::$reuseDB ) {
} else {
if ( $db->getType() == 'oracle' ) {
$db->query( 'BEGIN FILL_WIKI_INFO; END;' );
private function resetDB() {
if ( $this->db ) {
if ( $this->db->getType() == 'oracle' ) {
if ( self::$useTemporaryTables ) {
$this->db = wfGetDB( DB_MASTER );
} else {
foreach ( $this->tablesUsed as $tbl ) {
if ( $tbl == 'interwiki' ) {
$this->db->query( 'TRUNCATE TABLE ' . $this->db->tableName( $tbl ), __METHOD__ );
} else {
foreach ( $this->tablesUsed as $tbl ) {
if ( $tbl == 'interwiki' || $tbl == 'user' ) {
$this->db->delete( $tbl, '*', __METHOD__ );
public function __call( $func, $args ) {
static $compatibility = array(
'assertEmpty' => 'assertEmpty2', // assertEmpty was added in phpunit 3.7.32
if ( isset( $compatibility[$func] ) ) {
return call_user_func_array( array( $this, $compatibility[$func] ), $args );
} else {
throw new MWException( "Called non-existant $func method on "
. get_class( $this ) );
private function assertEmpty2( $value, $msg ) {
return $this->assertTrue( $value == '', $msg );
private static function unprefixTable( $tableName ) {
global $wgDBprefix;
return substr( $tableName, strlen( $wgDBprefix ) );
private static function isNotUnittest( $table ) {
return strpos( $table, 'unittest_' ) !== 0;
public static function listTables( $db ) {
global $wgDBprefix;
$tables = $db->listTables( $wgDBprefix, __METHOD__ );
if ( $db->getType() === 'mysql' ) {
# bug 43571: cannot clone VIEWs under MySQL
$views = $db->listViews( $wgDBprefix, __METHOD__ );
$tables = array_diff( $tables, $views );
$tables = array_map( array( __CLASS__, 'unprefixTable' ), $tables );
// Don't duplicate test tables from the previous fataled run
$tables = array_filter( $tables, array( __CLASS__, 'isNotUnittest' ) );
if ( $db->getType() == 'sqlite' ) {
$tables = array_flip( $tables );
// these are subtables of searchindex and don't need to be duped/dropped separately
unset( $tables['searchindex_content'] );
unset( $tables['searchindex_segdir'] );
unset( $tables['searchindex_segments'] );
$tables = array_flip( $tables );
return $tables;
protected function checkDbIsSupported() {
if ( !in_array( $this->db->getType(), $this->supportedDBs ) ) {
throw new MWException( $this->db->getType() . " is not currently supported for unit testing." );
public function getCliArg( $offset ) {
public function setCliArg( $offset, $value ) {
public function hideDeprecated( $function ) {
wfDeprecated( $function );
protected function assertSelect( $table, $fields, $condition, array $expectedRows ) {
if ( !$this->needsDB() ) {
throw new MWException( 'When testing database state, the test cases\'s needDB()' .
' method should return true. Use @group Database or $this->tablesUsed.' );
$res = $db->select( $table, $fields, $condition, wfGetCaller(), array( 'ORDER BY' => $fields ) );
$this->assertNotEmpty( $res, "query failed: " . $db->lastError() );
$i = 0;
foreach ( $expectedRows as $expected ) {
$r = $res->fetchRow();
$i += 1;
$this->assertNotEmpty( $r, "row #$i missing" );
$this->assertEquals( $expected, $r, "row #$i mismatches" );
$r = $res->fetchRow();
$this->assertFalse( $r, "found extra row (after #$i)" );
protected function arrayWrap( array $elements ) {
return array_map(
function ( $element ) {
return array( $element );
protected function assertArrayEquals( array $expected, array $actual, $ordered = false, $named = false ) {
if ( !$ordered ) {
$this->objectAssociativeSort( $expected );
$this->objectAssociativeSort( $actual );
if ( !$named ) {
$expected = array_values( $expected );
$actual = array_values( $actual );
array( $this, 'assertEquals' ),
array_merge( array( $expected, $actual ), array_slice( func_get_args(), 4 ) )
protected function assertHTMLEquals( $expected, $actual, $msg = '' ) {
$expected = str_replace( '>', ">\n", $expected );
$actual = str_replace( '>', ">\n", $actual );
$this->assertEquals( $expected, $actual, $msg );
protected function objectAssociativeSort( array &$array ) {
function ( $a, $b ) {
return serialize( $a ) > serialize( $b ) ? 1 : -1;
protected static function stripStringKeys( &$r ) {
if ( !is_array( $r ) ) {
foreach ( $r as $k => $v ) {
if ( is_string( $k ) ) {
unset( $r[$k] );
protected function assertTypeOrValue( $type, $actual, $value = false, $message = '' ) {
if ( $actual === $value ) {
$this->assertTrue( true, $message );
} else {
$this->assertType( $type, $actual, $message );
protected function assertType( $type, $actual, $message = '' ) {
if ( class_exists( $type ) || interface_exists( $type ) ) {
$this->assertInstanceOf( $type, $actual, $message );
} else {
$this->assertInternalType( $type, $actual, $message );
protected function isWikitextNS( $ns ) {
global $wgNamespaceContentModels;
if ( isset( $wgNamespaceContentModels[$ns] ) ) {
return $wgNamespaceContentModels[$ns] === CONTENT_MODEL_WIKITEXT;
return true;
protected function getDefaultWikitextNS() {
global $wgNamespaceContentModels;
static $wikitextNS = null; // this is not going to change
if ( $wikitextNS !== null ) {
return $wikitextNS;
// quickly short out on most common case:
if ( !isset( $wgNamespaceContentModels[NS_MAIN] ) ) {
return NS_MAIN;
// NOTE: prefer content namespaces
$namespaces = array_unique( array_merge(
array( NS_MAIN, NS_HELP, NS_PROJECT ), // prefer these
) );
$namespaces = array_diff( $namespaces, array(
NS_FILE, NS_CATEGORY, NS_MEDIAWIKI, NS_USER // don't mess with magic namespaces
) );
$talk = array_filter( $namespaces, function ( $ns ) {
return MWNamespace::isTalk( $ns );
} );
// prefer non-talk pages
$namespaces = array_diff( $namespaces, $talk );
$namespaces = array_merge( $namespaces, $talk );
// check default content model of each namespace
foreach ( $namespaces as $ns ) {
if ( !isset( $wgNamespaceContentModels[$ns] ) ||
$wgNamespaceContentModels[$ns] === CONTENT_MODEL_WIKITEXT
) {
$wikitextNS = $ns;
return $wikitextNS;
// give up
// @todo Inside a test, we could skip the test as incomplete.
// But frequently, this is used in fixture setup.
throw new MWException( "No namespace defaults to wikitext!" );
protected function checkHasDiff3() {
global $wgDiff3;
# This check may also protect against code injection in
# case of broken installations.
$haveDiff3 = $wgDiff3 && file_exists( $wgDiff3 );
if ( !$haveDiff3 ) {
$this->markTestSkipped( "Skip test, since diff3 is not configured" );
protected function checkHasGzip() {
static $haveGzip;
if ( $haveGzip === null ) {
$retval = null;
wfShellExec( 'gzip -V', $retval );
$haveGzip = ( $retval === 0 );
if ( !$haveGzip ) {
$this->markTestSkipped( "Skip test, requires the gzip utility in PATH" );
return $haveGzip;
protected function checkPHPExtension( $extName ) {
$loaded = extension_loaded( $extName );
if ( !$loaded ) {
$this->markTestSkipped( "PHP extension '$extName' is not loaded, skipping." );
return $loaded;
protected function assertException( $code, $expected = 'Exception', $message = '' ) {
$pokemons = null;
try {
call_user_func( $code );
} catch ( Exception $pokemons ) {
// Gotta Catch 'Em All!
if ( $message === '' ) {
$message = 'An exception of type "' . $expected . '" should have been thrown';
$this->assertInstanceOf( $expected, $pokemons, $message );
protected function assertValidHtmlSnippet( $html ) {
$html = '<!DOCTYPE html><html><head><title>test</title></head><body>' . $html . '</body></html>';
protected function assertValidHtmlDocument( $html ) {
// Note: we only validate if the tidy PHP extension is available.
// In case wgTidyInternal is false, MWTidy would fall back to the command line version
// of tidy. In that case however, we can not reliably detect whether a failing validation
// is due to malformed HTML, or caused by tidy not being installed as a command line tool.
// That would cause all HTML assertions to fail on a system that has no tidy installed.
if ( !$GLOBALS['wgTidyInternal'] ) {
$this->markTestSkipped( 'Tidy extension not installed' );
$errorBuffer = '';
MWTidy::checkErrors( $html, $errorBuffer );
$allErrors = preg_split( '/[\r\n]+/', $errorBuffer );
// Filter Tidy warnings which aren't useful for us.
// Tidy eg. often cries about parameters missing which have actually
// been deprecated since HTML4, thus we should not care about them.
$errors = preg_grep(
'/^(.*Warning: (trimming empty|.* lacks ".*?" attribute).*|\s*)$/m',
$this->assertEmpty( $errors, implode( "\n", $errors ) );
static unprefixTable( $tableName)
Definition: MediaWikiTestCase.php:601
static $reuseDB
Definition: MediaWikiTestCase.php:39
assertValidHtmlDocument( $html)
Asserts that the given string is valid HTML document.
Definition: MediaWikiTestCase.php:1071
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1528
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:189
assertArrayEquals(array $expected, array $actual, $ordered=false, $named=false)
Assert that two arrays are equal.
Definition: MediaWikiTestCase.php:764
Definition: Defines.php:56
wfShellExec( $cmd, &$retval=null, $environ=array(), $limits=array(), $options=array())
Execute a shell command, with time and memory limits mirrored from the PHP configuration if supported...
Definition: GlobalFunctions.php:2804
stashMwGlobals( $globalKeys)
Stashes the global, will be restored in tearDown()
Definition: MediaWikiTestCase.php:329
const NS_HELP
Definition: Defines.php:91
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
static getValidNamespaces()
Returns an array of the namespaces (by integer id) that exist on the wiki.
Definition: Namespace.php:273
static isTalk( $index)
Is the given namespace a talk namespace?
Definition: Namespace.php:107
mergeMwGlobalArrayValue( $name, $values)
Merges the given values into a MW global array variable.
Definition: MediaWikiTestCase.php:369
This is a test of the interface, mainly.
Definition: HashBagOStuff.php:30
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition: hooks.txt:1530
namespace and then decline to actually register it RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
Definition: hooks.txt:815
static stripStringKeys(&$r)
Utility function for eliminating all string keys from an array.
Definition: MediaWikiTestCase.php:825
wfMkdirParents( $dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
Definition: GlobalFunctions.php:2590
array $tmpFiles
Holds the paths of temporary files/directories created through getNewTempFile, and getNewTempDirector...
Definition: MediaWikiTestCase.php:54
wfGetLB( $wiki=false)
Get a load balancer object.
Definition: GlobalFunctions.php:3669
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3659
isWikitextNS( $ns)
Returns true if the given namespace defaults to Wikitext according to $wgNamespaceContentModels.
Definition: MediaWikiTestCase.php:886
query( $sql, $fname=__METHOD__, $tempIgnore=false)
Run an SQL query and return the result.
Definition: Database.php:1001
Definition: MediaWikiTestCase.php:399
wfProfileIn( $functionname)
Begin profiling of a function.
Definition: Profiler.php:33
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
Definition: GlobalFunctions.php:2387
static $useTemporaryTables
Definition: MediaWikiTestCase.php:38
const NS_FILE
Definition: Defines.php:85
Definition: MediaWikiTestCase.php:649
getCliArg( $offset)
Definition: MediaWikiTestCase.php:658
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:389
Make sure MediaWikiTestCase extending classes have called their parent setUp method.
Definition: MediaWikiTestCase.php:264
as a message key or array as accepted by ApiBase::dieUsageMsg after processing request parameters Return false to let the request fail
Definition: hooks.txt:375
assertValidHtmlSnippet( $html)
Asserts that the given string is a valid HTML snippet.
Definition: MediaWikiTestCase.php:1055
static isNotUnittest( $table)
Definition: MediaWikiTestCase.php:607
Definition: Defines.php:283
__construct( $name=null, array $data=array(), $dataName='')
Definition: MediaWikiTestCase.php:79
static getContentNamespaces()
Get a list of all namespace indices which are considered to contain content.
Definition: Namespace.php:334
static teardownTestDB()
Restores MediaWiki to using the table set (table prefix) it was using before setupTestDB() was called...
Definition: MediaWikiTestCase.php:481
static $users
Definition: MediaWikiTestCase.php:26
__call( $func, $args)
Definition: MediaWikiTestCase.php:581
$called tracks whether the setUp and tearDown method has been called.
Definition: MediaWikiTestCase.php:20
const NS_MAIN
Definition: Defines.php:79
Check, if $wgDiff3 is set and ready to merge Will mark the calling test as skipped,...
Definition: MediaWikiTestCase.php:959
Empty all tables so they can be repopulated for tests.
Definition: MediaWikiTestCase.php:547
MediaWiki exception.
Definition: MWException.php:26
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:103
Definition: Defines.php:83
static $additionalOptions
Definition: MediaWikiPHPUnitCommand.php:5
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1127
int $phpErrorLevel
Original value of PHP's error_reporting setting.
Definition: MediaWikiTestCase.php:47
select( $table, $vars, $conds='', $fname=__METHOD__, $options=array(), $join_conds=array())
Execute a SELECT query constructed using the various parameters provided.
Definition: Database.php:1575
Restore error level to previous value.
Definition: GlobalFunctions.php:2417
assertSelect( $table, $fields, $condition, array $expectedRows)
Asserts that the given database query yields the rows given by $expectedRows.
Definition: MediaWikiTestCase.php:703
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:302
Obtains a new temporary file name.
Definition: MediaWikiTestCase.php:156
Definition: MediaWikiTestCase.php:423
run(PHPUnit_Framework_TestResult $result=null)
Definition: MediaWikiTestCase.php:86
Definition: MediaWikiTestCase.php:6
static $oldTablePrefix
Definition: MediaWikiTestCase.php:41
static $instances
Definition: ObjectCache.php:30
hideDeprecated( $function)
Don't throw a warning if $function is deprecated and called later.
Definition: MediaWikiTestCase.php:679
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Definition: Profiler.php:46
listTables( $prefix=null, $fname=__METHOD__)
List all tables on the database.
Definition: Database.php:3558
assertException( $code, $expected='Exception', $message='')
Asserts that an exception of the specified type occurs when running the provided code.
Definition: MediaWikiTestCase.php:1025
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
assertEmpty2( $value, $msg)
Used as a compatibility method for phpunit < 3.7.32.
Definition: MediaWikiTestCase.php:597
Returns the ID of a namespace that defaults to Wikitext.
Definition: MediaWikiTestCase.php:903
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
Definition: Defines.php:93
Content object for wiki text pages.
Definition: WikitextContent.php:33
arrayWrap(array $elements)
Utility method taking an array of elements and wrapping each element in it's own array.
Definition: MediaWikiTestCase.php:743
Get the type of the DBMS, as it appears in $wgDBtype.
Check whether we have the 'gzip' commandline utility, will skip the test whenever "gzip -V" fails.
Definition: MediaWikiTestCase.php:983
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
assertHTMLEquals( $expected, $actual, $msg='')
Put each HTML element on its own line and then equals() the results.
Definition: MediaWikiTestCase.php:793
Definition: styleTest.css.php:45
assertTypeOrValue( $type, $actual, $value=false, $message='')
Asserts that the provided variable is of the specified internal type or equals the $value argument.
Definition: MediaWikiTestCase.php:850
DatabaseBase $db
Definition: MediaWikiTestCase.php:31
Definition: MediaWikiTestCase.php:391
Database abstraction object.
Definition: Database.php:219
static setupTestDB(DatabaseBase $db, $prefix)
Creates an empty skeleton of the wiki database by cloning its structure to equivalent tables using th...
Definition: MediaWikiTestCase.php:513
static listTables( $db)
Definition: MediaWikiTestCase.php:618
Get a description of the last error.
Definition: MediaWikiTestCase.php:420
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
Definition: MediaWikiTestCase.php:187
objectAssociativeSort(array &$array)
Does an associative sort that works for objects.
Definition: MediaWikiTestCase.php:807
const EDIT_NEW
Definition: Defines.php:189
Table name prefixes.
Definition: MediaWikiTestCase.php:66
if( $line===false) $args
Definition: cdb.php:62
const DB_SLAVE
Definition: Defines.php:55
namespace and then decline to actually register it & $namespaces
Definition: hooks.txt:815
Tries to get the system directory for temporary files.
Definition: GlobalFunctions.php:2564
array $supportedDBs
Definition: MediaWikiTestCase.php:72
Definition: CloneDatabase.php:27
listViews( $prefix=null, $fname=__METHOD__)
Lists all the VIEWs in the database.
Definition: Database.php:3581
Definition: MediaWikiTestCase.php:67
static changePrefix( $prefix)
Change the table prefix on all open DB connections/.
Definition: CloneDatabase.php:114
static resetIdByNameCache()
Reset the cache used in idFromName().
Definition: User.php:535
wfRecursiveRemoveDir( $dir)
Remove a directory and all its content.
Definition: GlobalFunctions.php:2632
array $tablesUsed
Definition: MediaWikiTestCase.php:36
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
const NS_USER
Definition: Defines.php:81
checkPHPExtension( $extName)
Check if $extName is a loaded PHP extension, will skip the test whenever it is not loaded.
Definition: MediaWikiTestCase.php:1005
Definition: Defines.php:87
array $mwGlobals
Holds original values of MediaWiki configuration settings to be restored in tearDown().
Definition: MediaWikiTestCase.php:61
static checkErrors( $text, &$errorStr=null)
Check HTML for errors, used if $wgValidateAllHtml = true.
Definition: Tidy.php:159
Definition: MediaWikiTestCase.php:143
if( $useReadline) $e
Definition: eval.php:66
assertType( $type, $actual, $message='')
Asserts the type of the provided value.
Definition: MediaWikiTestCase.php:869
setCliArg( $offset, $value)
Definition: MediaWikiTestCase.php:667
Definition: database.txt:21
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account incomplete not yet checked for validity & $retval
Definition: hooks.txt:237
wfGetCaller( $level=2)
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfG...
Definition: GlobalFunctions.php:1941
Definition: ComposerHookHandler.php:6
const CACHE_DB
Definition: Defines.php:113
Definition: MediaWikiTestCase.php:216
static $dbSetup
Definition: MediaWikiTestCase.php:40
Definition: testCompression.php:46
obtains a new temporary directory
Definition: MediaWikiTestCase.php:173