// Try memcached
global $wgMemc;
- global $wgContLang;
$memcKey = wfMemcKey(
'backlinks',
$batchSize
);
- if ( $wgContLang === null ) $wgContLang = new Language;
- if ( $wgMemc === null ) $wgMemc =& wfGetMainCache();
-
$memcValue = $wgMemc->get( $memcKey );
if ( is_array( $memcValue ) ) {
/**
* Returns a wikitext link to the DB's website, e.g.,
- * return "[http://www.mysql.com/ MySQL]";
+ * return "[http://www.mysql.com/ MySQL]";
* Should at least contain plain text, if for some reason
* your database has no website.
*
* Set a flag for this connection
*
* @param $flag Integer: DBO_* constants from Defines.php:
- * - DBO_DEBUG: output some debug info (same as debug())
- * - DBO_NOBUFFER: don't buffer results (inverse of bufferResults())
- * - DBO_IGNORE: ignore errors (same as ignoreErrors())
- * - DBO_TRX: automatically start transactions
- * - DBO_DEFAULT: automatically sets DBO_TRX if not in command line mode
- * and removes it in command line mode
- * - DBO_PERSISTENT: use persistant database connection
+ * - DBO_DEBUG: output some debug info (same as debug())
+ * - DBO_NOBUFFER: don't buffer results (inverse of bufferResults())
+ * - DBO_IGNORE: ignore errors (same as ignoreErrors())
+ * - DBO_TRX: automatically start transactions
+ * - DBO_DEFAULT: automatically sets DBO_TRX if not in command line mode
+ * and removes it in command line mode
+ * - DBO_PERSISTENT: use persistant database connection
*/
function setFlag( $flag ) {
$this->mFlags |= $flag;
}
}
- protected function connectionErrorHandler( $errno, $errstr ) {
+ protected function connectionErrorHandler( $errno, $errstr ) {
$this->mPHPError = $errstr;
}
/**
* Usually aborts on failure. If errors are explicitly ignored, returns success.
*
- * @param $sql String: SQL query
- * @param $fname String: Name of the calling function, for profiling/SHOW PROCESSLIST
- * comment (you can use __METHOD__ or add some extra info)
- * @param $tempIgnore Boolean: Whether to avoid throwing an exception on errors...
- * maybe best to catch the exception instead?
+ * @param $sql String: SQL query
+ * @param $fname String: Name of the calling function, for profiling/SHOW PROCESSLIST
+ * comment (you can use __METHOD__ or add some extra info)
+ * @param $tempIgnore Boolean: Whether to avoid throwing an exception on errors...
+ * maybe best to catch the exception instead?
* @return true for a successful write query, ResultWrapper object for a successful read query,
- * or false on failure if $tempIgnore set
+ * or false on failure if $tempIgnore set
* @throws DBQueryError Thrown when the database returns an error of any kind
*/
public function query( $sql, $fname = '', $tempIgnore = false ) {
$cnt++;
$sqlx = substr( $commentedSql, 0, 500 );
- $sqlx = strtr( $sqlx, "\t\n", ' ' );
+ $sqlx = strtr( $sqlx, "\t\n", ' ' );
if ( $isMaster ) {
wfDebug( "Query $cnt (master): $sqlx\n" );
if ( $this->ping() ) {
wfDebug( "Reconnected\n" );
$sqlx = substr( $commentedSql, 0, 500 );
- $sqlx = strtr( $sqlx, "\t\n", ' ' );
+ $sqlx = strtr( $sqlx, "\t\n", ' ' );
global $wgRequestTime;
$elapsed = round( microtime( true ) - $wgRequestTime, 3 );
wfLogDBError( "Connection lost and reconnected after {$elapsed}s, query: $sqlx\n" );
* ? = scalar value, quoted as necessary
* ! = raw SQL bit (a function for instance)
* & = filename; reads the file and inserts as a blob
- * (we don't use this though...)
+ * (we don't use this though...)
*/
function prepare( $sql, $func = 'DatabaseBase::prepare' ) {
/* MySQL doesn't support prepared statements (yet), so just
* @param $res Mixed: A SQL result
*/
function freeResult( $res ) {
- # Stub. Might not really need to be overridden, since results should
+ # Stub. Might not really need to be overridden, since results should
# be freed by PHP when the variable goes out of scope anyway.
}
* @private
*
* @param $options Array: associative array of options to be turned into
- * an SQL query, valid keys are listed in the function.
+ * an SQL query, valid keys are listed in the function.
* @return Array
*/
function makeSelectOptions( $options ) {
* SELECT wrapper
*
* @param $table Mixed: Array or string, table name(s) (prefix auto-added)
- * @param $vars Mixed: Array or string, field name(s) to be retrieved
+ * @param $vars Mixed: Array or string, field name(s) to be retrieved
* @param $conds Mixed: Array or string, condition(s) for WHERE
* @param $fname String: Calling function name (use __METHOD__) for logs/profiling
* @param $options Array: Associative array of options (e.g. array('GROUP BY' => 'page_title')),
- * see DatabaseBase::makeSelectOptions code for list of supported stuff
+ * see DatabaseBase::makeSelectOptions code for list of supported stuff
* @param $join_conds Array: Associative array of table join conditions (optional)
- * (e.g. array( 'page' => array('LEFT JOIN','page_latest=rev_id') )
+ * (e.g. array( 'page' => array('LEFT JOIN','page_latest=rev_id') )
* @return mixed Database result resource (feed to DatabaseBase::fetchObject or whatever), or false on failure
*/
function select( $table, $vars, $conds = '', $fname = 'DatabaseBase::select', $options = array(), $join_conds = array() ) {
* SELECT wrapper
*
* @param $table Mixed: Array or string, table name(s) (prefix auto-added)
- * @param $vars Mixed: Array or string, field name(s) to be retrieved
+ * @param $vars Mixed: Array or string, field name(s) to be retrieved
* @param $conds Mixed: Array or string, condition(s) for WHERE
* @param $fname String: Calling function name (use __METHOD__) for logs/profiling
* @param $options Array: Associative array of options (e.g. array('GROUP BY' => 'page_title')),
- * see DatabaseBase::makeSelectOptions code for list of supported stuff
+ * see DatabaseBase::makeSelectOptions code for list of supported stuff
* @param $join_conds Array: Associative array of table join conditions (optional)
- * (e.g. array( 'page' => array('LEFT JOIN','page_latest=rev_id') )
+ * (e.g. array( 'page' => array('LEFT JOIN','page_latest=rev_id') )
* @return string, the SQL text
*/
function selectSQLText( $table, $vars, $conds = '', $fname = 'DatabaseBase::select', $options = array(), $join_conds = array() ) {
* @param $table String: table name
* @param $vars String: the selected variables
* @param $conds Array: a condition map, terms are ANDed together.
- * Items with numeric keys are taken to be literal conditions
+ * Items with numeric keys are taken to be literal conditions
* Takes an array of selected variables, and a condition map, which is ANDed
* e.g: selectRow( "page", array( "page_id" ), array( "page_namespace" =>
- * NS_MAIN, "page_title" => "Astronomy" ) ) would return an object where
+ * NS_MAIN, "page_title" => "Astronomy" ) ) would return an object where
* $obj- >page_id is the ID of the Astronomy article
* @param $fname String: Calling function name
* @param $options Array
* @param $values Array: An array of values to SET
* @param $conds Array: An array of conditions (WHERE). Use '*' to update all rows.
* @param $fname String: The Class::Function calling this function
- * (for the log)
+ * (for the log)
* @param $options Array: An array of UPDATE options, can be one or
- * more of IGNORE, LOW_PRIORITY
+ * more of IGNORE, LOW_PRIORITY
* @return Boolean
*/
function update( $table, $values, $conds, $fname = 'DatabaseBase::update', $options = array() ) {
/**
* Makes an encoded list of strings from an array
* $mode:
- * LIST_COMMA - comma separated, no field names
- * LIST_AND - ANDed WHERE clause (without the WHERE)
- * LIST_OR - ORed WHERE clause (without the WHERE)
- * LIST_SET - comma separated with field names, like a SET clause
- * LIST_NAMES - comma separated field names
+ * LIST_COMMA - comma separated, no field names
+ * LIST_AND - ANDed WHERE clause (without the WHERE)
+ * LIST_OR - ORed WHERE clause (without the WHERE)
+ * LIST_SET - comma separated with field names, like a SET clause
+ * LIST_NAMES - comma separated field names
*/
function makeList( $a, $mode = LIST_COMMA ) {
if ( !is_array( $a ) ) {
* @return bool Success or failure
*/
function selectDB( $db ) {
- # Stub. Shouldn't cause serious problems if it's not overridden, but
+ # Stub. Shouldn't cause serious problems if it's not overridden, but
# if your database engine supports a concept similar to MySQL's
# databases you may as well.
return true;
&& is_array( $wgSharedTables )
&& in_array( $table, $wgSharedTables ) ) { # A shared table is selected
$database = $wgSharedDB;
- $prefix = isset( $wgSharedPrefix ) ? $wgSharedPrefix : $prefix;
+ $prefix = isset( $wgSharedPrefix ) ? $wgSharedPrefix : $prefix;
}
# Quote the $database and $table and apply the prefix if not quoted.
* Example:
* extract($dbr->tableNames('user','watchlist'));
* $sql = "SELECT wl_namespace,wl_title FROM $watchlist,$user
- * WHERE wl_user=user_id AND wl_user=$nameWithQuotes";
+ * WHERE wl_user=user_id AND wl_user=$nameWithQuotes";
*/
public function tableNames() {
$inArray = func_get_args();
* Example:
* list( $user, $watchlist ) = $dbr->tableNamesN('user','watchlist');
* $sql = "SELECT wl_namespace,wl_title FROM $watchlist,$user
- * WHERE wl_user=user_id AND wl_user=$nameWithQuotes";
+ * WHERE wl_user=user_id AND wl_user=$nameWithQuotes";
*/
public function tableNamesN() {
$inArray = func_get_args();
}
/**
- * USE INDEX clause. Unlikely to be useful for anything but MySQL. This
+ * USE INDEX clause. Unlikely to be useful for anything but MySQL. This
* is only needed because a) MySQL must be as efficient as possible due to
* its use on Wikipedia, and b) MySQL 4.0 is kind of dumb sometimes about
- * which index to pick. Anyway, other databases might have different
+ * which index to pick. Anyway, other databases might have different
* indexes on a given table. So don't bother overriding this unless you're
* MySQL.
*/
list( $startOpts, $useIndex, $tailOpts ) = $this->makeSelectOptions( $selectOptions );
if ( is_array( $srcTable ) ) {
- $srcTable = implode( ',', array_map( array( &$this, 'tableName' ), $srcTable ) );
+ $srcTable = implode( ',', array_map( array( &$this, 'tableName' ), $srcTable ) );
} else {
$srcTable = $this->tableName( $srcTable );
}
* If the result of the query is not ordered, then the rows to be returned
* are theoretically arbitrary.
*
- * $sql is expected to be a SELECT, if that makes a difference. For
+ * $sql is expected to be a SELECT, if that makes a difference. For
* UPDATE, limitResultForUpdate should be used.
*
* The version provided by default works in MySQL and SQLite. It will very
}
/**
- * Returns an SQL expression for a simple conditional. This doesn't need
+ * Returns an SQL expression for a simple conditional. This doesn't need
* to be overridden unless CASE isn't supported in your DBMS.
*
* @param $cond String: SQL expression which will result in a boolean value
* will be rolled back and the callback function will be called again.
*
* Usage:
- * $dbw->deadlockLoop( callback, ... );
+ * $dbw->deadlockLoop( callback, ... );
*
* Extra arguments are passed through to the specified callback function.
*
* @return bool Success or failure
*/
function ping() {
- # Stub. Not essential to override.
+ # Stub. Not essential to override.
return true;
}
}
/**
- * Override database's default connection timeout. May be useful for very
+ * Override database's default connection timeout. May be useful for very
* long batch queries such as full-wiki dumps, where a single query reads
- * out over hours or days. May or may not be necessary for non-MySQL
+ * out over hours or days. May or may not be necessary for non-MySQL
* databases. For most purposes, leaving it as a no-op should be fine.
*
* @param $timeout Integer in seconds
* @param $lineCallback Callback: Optional function called before reading each line
* @param $resultCallback Callback: Optional function called for each MySQL result
* @param $fname String: Calling function name or false if name should be generated dynamically
- * using $filename
+ * using $filename
*/
function sourceFile( $filename, $lineCallback = false, $resultCallback = false, $fname = false ) {
$fp = fopen( $filename, 'r' );
$mainpage = 'Main Page';
if ( $wgLang instanceof Language ) {
- $mainpage = htmlspecialchars( $wgLang->getMessage( 'mainpage' ) );
+ $mainpage = htmlspecialchars( $wgLang->getMessage( 'mainpage' ) );
}
if ( $wgTitle ) {
public $error, $errno, $sql, $fname;
function __construct( DatabaseBase &$db, $error, $errno, $sql, $fname ) {
- $message = "A database error has occurred. Did you forget to run maintenance/update.php after upgrading? See: http://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n" .
+ $message = "A database error has occurred. Did you forget to run maintenance/update.php after upgrading? See: http://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n" .
"Query: $sql\n" .
"Function: $fname\n" .
"Error: $errno $error\n";
* doesn't go anywhere near an actual database.
*/
class FakeResultWrapper extends ResultWrapper {
- var $result = array();
- var $db = null; // And it's going to stay that way :D
- var $pos = 0;
+ var $result = array();
+ var $db = null; // And it's going to stay that way :D
+ var $pos = 0;
var $currentRow = null;
function __construct( $array ) {
/**
* @param $params Array with keys:
- * servers Required. Array of server info structures.
- * failFunction Deprecated, use exceptions instead.
- * masterWaitTimeout Replication lag wait timeout
- * loadMonitor Name of a class used to fetch server lag and load.
+ * servers Required. Array of server info structures.
+ * failFunction Deprecated, use exceptions instead.
+ * masterWaitTimeout Replication lag wait timeout
+ * loadMonitor Name of a class used to fetch server lag and load.
*/
function __construct( $params )
{
$this->mLaggedSlaveMode = false;
$this->mErrorConnection = false;
$this->mAllowLag = false;
- $this->mLoadMonitorClass = isset( $params['loadMonitor'] )
+ $this->mLoadMonitorClass = isset( $params['loadMonitor'] )
? $params['loadMonitor'] : 'LoadMonitor_MySQL';
foreach( $params['servers'] as $i => $server ) {
$i = $this->pickRandom( $currentLoads );
} else {
$i = $this->getRandomNonLagged( $currentLoads, $wiki );
- if ( $i === false && count( $currentLoads ) != 0 ) {
+ if ( $i === false && count( $currentLoads ) != 0 ) {
# All slaves lagged. Switch to read-only mode
$wgReadOnly = wfMsgNoDBForContent( 'readonly_lag' );
$i = $this->pickRandom( $currentLoads );
if ( $i === false ) {
# pickRandom() returned false
- # This is permanent and means the configuration or the load monitor
+ # This is permanent and means the configuration or the load monitor
# wants us to return false.
wfDebugLog( 'connect', __METHOD__.": pickRandom() returned false\n" );
wfProfileOut( __METHOD__ );
}
// Perform post-connection backoff
- $threshold = isset( $this->mServers[$i]['max threads'] )
+ $threshold = isset( $this->mServers[$i]['max threads'] )
? $this->mServers[$i]['max threads'] : false;
$backoff = $this->getLoadMonitor()->postConnectionBackoff( $conn, $threshold );
if ( $wiki !== false ) {
$this->reuseConnection( $conn );
}
-
+
if ( $backoff ) {
# Post-connection overload, don't use this server for now
$totalThreadsConnected += $backoff;
/**
* Get a connection by index
* This is the main entry point for this class.
- *
+ *
* @param $i Integer: server index
* @param $groups Array: query groups
* @param $wiki String: wiki ID
- *
+ *
* @return DatabaseBase
*/
public function &getConnection( $i, $groups = array(), $wiki = false ) {
wfDebug( __METHOD__.": this connection was not opened as a foreign connection\n" );
/**
* This can happen in code like:
- * foreach ( $dbs as $db ) {
- * $conn = $lb->getConnection( DB_SLAVE, array(), $db );
- * ...
- * $lb->reuseConnection( $conn );
- * }
+ * foreach ( $dbs as $db ) {
+ * $conn = $lb->getConnection( DB_SLAVE, array(), $db );
+ * ...
+ * $lb->reuseConnection( $conn );
+ * }
* When a connection to the local DB is opened in this way, reuseConnection()
* should be ignored
*/
*/
function closeAll() {
foreach ( $this->mConns as $conns2 ) {
- foreach ( $conns2 as $conns3 ) {
+ foreach ( $conns2 as $conns3 ) {
foreach ( $conns3 as $conn ) {
$conn->close();
}
private $fuzzSeed = 0;
private $memoryLimit = 50;
- public $regex = "";
- private $savedGlobals = array();
-
/**
* Sets terminal colorization and diff/quick modes depending on OS and
* command-line options (--color and --quick).
: new DummyTermColorer();
$this->showDiffs = !isset( $options['quick'] );
- $this->showProgress = false; #!isset( $options['quiet'] );
- $this->showFailure = false; /* !( */
- /* isset( $options['quiet'] ) */
- /* && ( isset( $options['record'] ) */
- /* || isset( $options['compare'] ) ) ); // redundant output */
+ $this->showProgress = !isset( $options['quiet'] );
+ $this->showFailure = !(
+ isset( $options['quiet'] )
+ && ( isset( $options['record'] )
+ || isset( $options['compare'] ) ) ); // redundant output
$this->showOutput = isset( $options['show-output'] );
+
if ( isset( $options['regex'] ) ) {
if ( isset( $options['record'] ) ) {
echo "Warning: --record cannot be used with --regex, disabling --record\n";
$this->setupRecorder( $options );
$this->keepUploads = isset( $options['keep-uploads'] );
- $this->uploadDir = $this->setupUploadDir();
if ( isset( $options['seed'] ) ) {
$this->fuzzSeed = intval( $options['seed'] ) - 1;
}
}
+ /**
+ * Remove last character if it is a newline
+ */
+ public function chomp( $s ) {
+ if ( substr( $s, -1 ) === "\n" ) {
+ return substr( $s, 0, -1 );
+ }
+ else {
+ return $s;
+ }
+ }
+
/**
* Run a fuzz test series
* Draw input from a set of test files
}
- if ( method_exists( $this->recorder, "showTestResult" ) ) {
- return $this->recorder->showTestResult( $desc, $result, $out );
- } else if ( $result === $out && ( $noxml === true || $this->wellFormed( $out ) ) ) {
- return ParserTestSuiteBackend::showSuccess( $desc, $result, $out );
+ $this->teardownGlobals();
+
+ if ( $result === $out && ( $noxml === true || $this->wellFormed( $out ) ) ) {
+ return $this->showSuccess( $desc );
} else {
- return ParserTestSuiteBackend::showFailure( $desc, $result, $out );
+ return $this->showFailure( $desc, $result, $out );
}
}
'wgStyleSheetPath' => '/skins',
'wgSitename' => 'MediaWiki',
'wgLanguageCode' => $lang,
+ 'wgDBprefix' => $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_',
'wgRawHtml' => isset( $opts['rawhtml'] ),
'wgLang' => null,
'wgContLang' => null,
if ( $wgDBtype == 'oracle' )
$db->query( 'BEGIN FILL_WIKI_INFO; END;' );
- if ( ( $wgDBtype != 'oracle' && $wgDBprefix != 'parsertest_' )
- && $wgDBprefix != 'pt_' ) {
- $this->changePrefix( $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_' );
- }
+ $this->changePrefix( $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_' );
# Hack: insert a few Wikipedia in-project interwiki prefixes,
# for testing inter-language links
global $wgMessageCache, $wgMemc;
$wgMessageCache = new MessageCache( $wgMemc, true, 3600 );
+ $this->uploadDir = $this->setupUploadDir();
$user = User::createNew( 'WikiSysop' );
$image = wfLocalFile( Title::makeTitle( NS_FILE, 'Foobar.jpg' ) );
$image->recordUpload2( '', 'Upload of some lame file', 'Some lame file', array(
global $wgDBtype;
if ( !$this->databaseSetupDone ) {
- $this->teardownGlobals();
return;
}
$this->teardownUploadDir( $this->uploadDir );
if ( $this->useTemporaryTables ) {
# Don't need to do anything
- $this->teardownGlobals();
return;
}
if ( $wgDBtype == 'oracle' )
$db->query( 'BEGIN FILL_WIKI_INFO; END;' );
-
- $this->teardownGlobals();
}
/**
require_once( dirname( __FILE__ ) . '/../commandLine.inc' );
if ( isset( $options['help'] ) ) {
- echo <<<ENDS
+ echo <<<ENDS
MediaWiki $wgVersion parser test suite
Usage: php parserTests.php [options...]
Options:
- --quick Suppress diff output of failed tests
- --quiet Suppress notification of passed tests (shows only failed tests)
- --show-output Show expected and actual output
+ --quick Suppress diff output of failed tests
+ --quiet Suppress notification of passed tests (shows only failed tests)
+ --show-output Show expected and actual output
--color[=yes|no] Override terminal detection and force color output on or off
- use wgCommandLineDarkBg = true; if your term is dark
- --regex Only run tests whose descriptions which match given regex
+ use wgCommandLineDarkBg = true; if your term is dark
+ --regex Only run tests whose descriptions which match given regex
--file=<testfile> Run test cases from a custom file instead of parserTests.txt
- --record Record tests in database
- --compare Compare with recorded results, without updating the database.
- --setversion When using --record, set the version string to use (useful
- with git-svn so that you can get the exact revision)
+ --record Record tests in database
+ --compare Compare with recorded results, without updating the database.
+ --setversion When using --record, set the version string to use (useful
+ with git-svn so that you can get the exact revision)
--keep-uploads Re-use the same upload directory for each test, don't delete it
- --fuzz Do a fuzz test instead of a normal test
- --seed <n> Start the fuzz test from the specified seed
- --help Show this help message
+ --fuzz Do a fuzz test instead of a normal test
+ --seed <n> Start the fuzz test from the specified seed
+ --help Show this help message
--run-disabled run disabled tests
- --upload Upload test results to remote wiki (per \$wgParserTestRemote)
+ --upload Upload test results to remote wiki (per \$wgParserTestRemote)
ENDS;
- exit( 0 );
+ exit( 0 );
}
# Cases of weird db corruption were encountered when running tests on earlyish
-<?php
+<?php
/**
* Bootstrapping for MediaWiki PHPUnit tests
- *
+ *
* @file
*/
/* Classes */
abstract class MediaWikiTestSetup extends PHPUnit_Framework_TestCase {
- protected $suite;
- public $regex = '';
- public $runDisabled = false;
-
- function __construct( PHPUnit_Framework_TestSuite $suite = null ) {
- if ( null !== $suite ) {
- $this->suite = $suite;
- }
- }
-
- function __call( $func, $args ) {
- if ( method_exists( $this->suite, $func ) ) {
- return call_user_func_array( array( $tohis->suite, $func ), $args);
- } else {
- throw new MWException( "Called non-existant $func method on "
- . get_class( $this ) );
- }
- return false;
- }
-
- /**
- * @group utility
- */
- function getSuite() {
- return $this->suite;
- }
-
- /**
- * Remove last character if it is a newline
- * @group utility
- */
- public function chomp( $s ) {
- if ( substr( $s, -1 ) === "\n" ) {
- return substr( $s, 0, -1 );
- }
- else {
- return $s;
- }
- }
-
- public function addArticle( $name, $text, $line ) {
- global $wgCapitalLinks;
- $oldCapitalLinks = $wgCapitalLinks;
- $wgCapitalLinks = true; // We only need this from SetupGlobals() See r70917#c8637
-
- $title = Title::newFromText( $name );
-
- if ( is_null( $title ) ) {
- wfDie( "invalid title at line $line\n" );
- }
-
- $aid = $title->getArticleID( Title::GAID_FOR_UPDATE );
-
- if ( $aid != 0 ) {
- wfDie( "duplicate article '$name' at line $line\n" );
- }
-
- $art = new Article( $title );
- $art->insertNewArticle( $text, '', false, false );
-
- $wgCapitalLinks = $oldCapitalLinks;
- }
-
- /**
- * @group utility
- */
- function buildTestDatabase( $tables ) {
+ protected function buildTestDatabase( $tables ) {
global $wgDBprefix;
$db = wfGetDB( DB_MASTER );
$oldTableNames = array();
foreach ( $tables as $table )
$oldTableNames[$table] = $db->tableName( $table );
+ if ( $db->getType() == 'oracle' ) {
+ $wgDBprefix = 'pt_';
+ } else {
+ $wgDBprefix = 'parsertest_';
+ }
+
+ $db->tablePrefix( $wgDBprefix );
if ( $db->isOpen() ) {
foreach ( $tables as $tbl ) {
/*
* The file where the test temporarity stores the selenium config.
- * This should be cleaned up as part of teardown.
+ * This should be cleaned up as part of teardown.
*/
private $tempFileName;
-
+
/*
* String containing the a sample selenium settings
*/
- private $testConfig0 =
+ private $testConfig0 =
'
[SeleniumSettings]
-browsers[firefox] = "*firefox"
+browsers[firefox] = "*firefox"
browsers[iexplorer] = "*iexploreproxy"
-browsers[chrome] = "*chrome"
-host = "localhost"
-port = "foobarr"
-wikiUrl = "http://localhost/deployment"
-username = "xxxxxxx"
-userPassword = ""
-testBrowser = "chrome"
+browsers[chrome] = "*chrome"
+host = "localhost"
+port = "foobarr"
+wikiUrl = "http://localhost/deployment"
+username = "xxxxxxx"
+userPassword = ""
+testBrowser = "chrome"
[SeleniumTests]
testSuite[SimpleSeleniumTestSuite] = "maintenance/tests/selenium/SimpleSeleniumTestSuite.php"
-testSuite[TestSuiteName] = "testSuitePath"
+testSuite[TestSuiteName] = "testSuitePath"
';
/*
* Array of expected browsers from $testConfig0
private $testSettings0 = array(
'host' => 'localhost',
'port' => 'foobarr',
- 'wikiUrl' => 'http://localhost/deployment',
- 'username' => 'xxxxxxx',
- 'userPassword' => '',
- 'testBrowser' => 'chrome'
+ 'wikiUrl' => 'http://localhost/deployment',
+ 'username' => 'xxxxxxx',
+ 'userPassword' => '',
+ 'testBrowser' => 'chrome'
);
/*
* Array of expected testSuites from $testConfig0
*/
private $testSuites0 = array(
- 'SimpleSeleniumTestSuite' => 'maintenance/tests/selenium/SimpleSeleniumTestSuite.php',
- 'TestSuiteName' => 'testSuitePath'
+ 'SimpleSeleniumTestSuite' => 'maintenance/tests/selenium/SimpleSeleniumTestSuite.php',
+ 'TestSuiteName' => 'testSuitePath'
);
-
-
+
+
/*
* Another sample selenium settings file contents
*/
- private $testConfig1 =
+ private $testConfig1 =
'
[SeleniumSettings]
-host = "localhost"
-testBrowser = "firefox"
+host = "localhost"
+testBrowser = "firefox"
';
/*
* Expected browsers from $testConfig1
private $testSettings1 = array(
'host' => 'localhost',
'port' => null,
- 'wikiUrl' => null,
- 'username' => null,
- 'userPassword' => null,
- 'testBrowser' => 'firefox'
+ 'wikiUrl' => null,
+ 'username' => null,
+ 'userPassword' => null,
+ 'testBrowser' => 'firefox'
);
/*
* Expected test suites from $testConfig1
*/
- private $testSuites1 = null;
-
-
+ private $testSuites1 = null;
+
+
public function setUp() {
if ( !defined( 'SELENIUMTEST' ) ) {
define( 'SELENIUMTEST', true );
}
}
-
+
/*
* Clean up the temporary file used to store the selenium settings.
*/
}
parent::tearDown();
}
-
+
/**
- * @expectedException MWException
- * @group SeleniumFramework
- */
- public function testErrorOnIncorrectConfigFile() {
+ * @expectedException MWException
+ * @group SeleniumFramework
+ */
+ public function testErrorOnIncorrectConfigFile() {
$seleniumSettings;
$seleniumBrowsers;
$seleniumTestSuites;
- SeleniumConfig::getSeleniumSettings($seleniumSettings,
- $seleniumBrowsers,
+ SeleniumConfig::getSeleniumSettings($seleniumSettings,
+ $seleniumBrowsers,
$seleniumTestSuites,
"Some_fake_settings_file.ini" );
}
-
+
/**
- * @expectedException MWException
- * @group SeleniumFramework
- */
- public function testErrorOnMissingConfigFile() {
+ * @expectedException MWException
+ * @group SeleniumFramework
+ */
+ public function testErrorOnMissingConfigFile() {
$seleniumSettings;
$seleniumBrowsers;
$seleniumTestSuites;
global $wgSeleniumConfigFile;
$wgSeleniumConfigFile = '';
- SeleniumConfig::getSeleniumSettings($seleniumSettings,
- $seleniumBrowsers,
+ SeleniumConfig::getSeleniumSettings($seleniumSettings,
+ $seleniumBrowsers,
$seleniumTestSuites);
}
-
+
/**
- * @group SeleniumFramework
- */
- public function testUsesGlobalVarForConfigFile() {
+ * @group SeleniumFramework
+ */
+ public function testUsesGlobalVarForConfigFile() {
$seleniumSettings;
$seleniumBrowsers;
$seleniumTestSuites;
global $wgSeleniumConfigFile;
$this->writeToTempFile( $this->testConfig0 );
$wgSeleniumConfigFile = $this->tempFileName;
- SeleniumConfig::getSeleniumSettings($seleniumSettings,
- $seleniumBrowsers,
+ SeleniumConfig::getSeleniumSettings($seleniumSettings,
+ $seleniumBrowsers,
$seleniumTestSuites);
$this->assertEquals($seleniumSettings, $this->testSettings0 ,
'The selenium settings should have been read from the file defined in $wgSeleniumConfigFile'
);
- $this->assertEquals($seleniumBrowsers, $this->testBrowsers0,
+ $this->assertEquals($seleniumBrowsers, $this->testBrowsers0,
'The available browsers should have been read from the file defined in $wgSeleniumConfigFile'
);
- $this->assertEquals($seleniumTestSuites, $this->testSuites0,
+ $this->assertEquals($seleniumTestSuites, $this->testSuites0,
'The test suites should have been read from the file defined in $wgSeleniumConfigFile'
- );
+ );
}
/**
- * @group SeleniumFramework
- * @dataProvider sampleConfigs
- */
- public function testgetSeleniumSettings($sampleConfig, $expectedSettings, $expectedBrowsers, $expectedSuites ) {
+ * @group SeleniumFramework
+ * @dataProvider sampleConfigs
+ */
+ public function testgetSeleniumSettings($sampleConfig, $expectedSettings, $expectedBrowsers, $expectedSuites ) {
$this->writeToTempFile( $sampleConfig );
$seleniumSettings;
$seleniumBrowsers;
$seleniumTestSuites;
- SeleniumConfig::getSeleniumSettings($seleniumSettings,
- $seleniumBrowsers,
+ SeleniumConfig::getSeleniumSettings($seleniumSettings,
+ $seleniumBrowsers,
$seleniumTestSuites,
$this->tempFileName );
-
- $this->assertEquals($seleniumSettings, $expectedSettings,
+
+ $this->assertEquals($seleniumSettings, $expectedSettings,
"The selenium settings for the following test configuration was not retrieved correctly" . $sampleConfig
);
- $this->assertEquals($seleniumBrowsers, $expectedBrowsers,
+ $this->assertEquals($seleniumBrowsers, $expectedBrowsers,
"The available browsers for the following test configuration was not retrieved correctly" . $sampleConfig
);
- $this->assertEquals($seleniumTestSuites, $expectedSuites,
+ $this->assertEquals($seleniumTestSuites, $expectedSuites,
"The test suites for the following test configuration was not retrieved correctly" . $sampleConfig
);
-
-
+
+
}
-
+
/*
* create a temp file and write text to it.
* @param $testToWrite the text to write to the temp file
fwrite($tempFile , $textToWrite);
fclose($tempFile);
}
-
+
/*
* Returns an array containing:
- * The contents of the selenium cingiguration ini file
- * The expected selenium configuration array that getSeleniumSettings should return
- * The expected available browsers array that getSeleniumSettings should return
- * The expected test suites arrya that getSeleniumSettings should return
+ * The contents of the selenium cingiguration ini file
+ * The expected selenium configuration array that getSeleniumSettings should return
+ * The expected available browsers array that getSeleniumSettings should return
+ * The expected test suites arrya that getSeleniumSettings should return
*/
public function sampleConfigs() {
return array(
array($this->testConfig1, $this->testSettings1, $this->testBrowsers1, $this->testSuites1 )
);
}
-
+
}
self::$user = new UserWrapper( 'Useruser', 'Passpass' );
self::$sysopUser = new UserWrapper( 'Useruser1', 'Passpass1', 'sysop' );
}
-
+
$GLOBALS['wgUser'] = self::$sysopUser->user;
-
}
function tearDown() {
public function __construct( $userName, $password, $group = '' ) {
$this->userName = $userName;
- $this->password = $password;
-
- $this->user = User::newFromName( $this->userName );
+ $this->password = $password;
+ $this->user = User::newFromName( $this->userName );
if ( !$this->user->getID() ) {
$this->user = User::createNew( $this->userName, array(
"email" => "test@example.com",
if ( $group !== '' ) {
$this->user->addGroup( $group );
}
-
$this->user->saveSettings();
}
}
}
/**
- * @expectedException UsageException
- */
+ * @expectedException UsageException
+ */
function testRequireOnlyOneParameterZero() {
$mock = new MockApi();
}
/**
- * @expectedException UsageException
- */
+ * @expectedException UsageException
+ */
function testRequireOnlyOneParameterTrue() {
$mock = new MockApi();
"lgpassword" => "bad",
)
);
-
+
$result = $ret[0];
$this->assertNotType( "bool", $result );
libxml_use_internal_errors( true );
$sxe = simplexml_load_string( $req->getContent() );
-
$this->assertNotType( "bool", $sxe );
$this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) );
$this->assertNotType( "null", $sxe->login[0] );
$serializedCookie = $cj->serializeToHttpRequest( $wgScriptPath, $serverName );
$this->assertNotEquals( '', $serializedCookie );
$this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*; .*UserName=' . self::$user->userName . '; .*Token=/', $serializedCookie );
+
return $cj;
}
'action' => 'query',
'list' => 'watchlist' ), $data );
- $this->markTestIncomplete( 'This test needs to verify the deleted article was added to the users watchlist' );
+ $this->markTestIncomplete( 'This test needs to verify the deleted article was added to the users watchlist' );
}
}
<?php
require_once( dirname( __FILE__ ) . '/ParserHelpers.php' );
-require_once( dirname(dirname(dirname( __FILE__ ))) . '/bootstrap.php' );
-class MediaWikiParserTest extends MediaWikiTestSetup {
- public $count;
+class MediaWikiParserTest extends PHPUnit_Framework_TestSuite {
+ private $count;
public $backend;
- public function __construct( ) {
- $suite = new PHPUnit_Framework_TestSuite('Parser Tests');
- parent::__construct($suite);
+ public static function suite() {
+ return new self;
+ }
+
+ public function __construct() {
$this->backend = new ParserTestSuiteBackend;
+ parent::__construct();
$this->setName( 'Parser tests' );
}
- public static function suite() {
- global $IP;
+ public function run( PHPUnit_Framework_TestResult $result = null, $filter = false,
+ array $groups = array(), array $excludeGroups = array(), $processIsolation = false
+ ) {
+ global $IP, $wgContLang, $wgMemc;
+ $wgContLang = Language::factory( 'en' );
+ $wgMemc = new FakeMemCachedClient;
+ $this->backend->setupDatabase();
- $tester = new self;
$iter = new TestFileIterator( "$IP/maintenance/tests/parser/parserTests.txt" );
- $iter->setParser( $tester );
- $tester->count = 0;
+ $iter->setParser( $this->backend );
+ $this->count = 0;
foreach ( $iter as $test ) {
- $tester->suite->addTest( new ParserUnitTest( $tester, $test ) );
- $tester->count++;
+ $this->addTest( new ParserUnitTest( $this, $test ) );
+ $this->count++;
}
- return $tester->suite;
+ parent::run( $result, $filter, $groups, $excludeGroups, $processIsolation );
+
+ $this->backend->teardownDatabase();
}
public function count() {
$result = new PHPUnit_Framework_TestResult;
}
- $backend = new ParserTestSuiteBackend;
+ $backend = $this->suite->getBackend();
$result->startTest( $this );
-
+
// Support the transition to PHPUnit 3.5 where PHPUnit_Util_Timer is replaced with PHP_Timer
if ( class_exists( 'PHP_Timer' ) ) {
PHP_Timer::start();
# Run the test.
# On failure, the subclassed backend will throw an exception with
# the details.
- $pt = new ParserTest;
- $r = $pt->runTest( $this->test['test'], $this->test['input'],
- $this->test['result'], $this->test['options'], $this->test['config']
+ $r = $backend->runTest(
+ $this->test['test'],
+ $this->test['input'],
+ $this->test['result'],
+ $this->test['options'],
+ $this->test['config']
);
}
catch ( PHPUnit_Framework_AssertionFailedError $e ) {
}
-class ParserTestSuiteBackend extends PHPUnit_FrameWork_TestSuite {
- public $recorder;
- public $term;
- static $usePHPUnit = false;
-
- function __construct() {
- parent::__construct();
- $this->setupRecorder(null);
- self::$usePHPUnit = method_exists('PHPUnit_Framework_Assert', 'assertEquals');
- }
-
+class ParserTestSuiteBackend extends ParserTest {
function showTesting( $desc ) {
}
function showRunFile( $path ) {
}
- function showTestResult( $desc, $result, $out ) {
- if ( $result === $out ) {
- return self::showSuccess( $desc, $result, $out );
- } else {
- return self::showFailure( $desc, $result, $out );
- }
- }
-
- public static function showSuccess( $desc, $expected, $got ) {
- if ( self::$usePHPUnit ) {
- PHPUnit_Framework_Assert::assertEquals( $expected, $got, $desc );
- }
+ function showSuccess( $desc ) {
+ PHPUnit_Framework_Assert::assertTrue( true, $desc );
return true;
}
- public static function showFailure( $desc, $expected, $got ) {
- if ( self::$usePHPUnit ) {
- PHPUnit_Framework_Assert::assertEquals( $expected, $got, $desc );
- }
- return false;
+ function showFailure( $desc, $expected, $got ) {
+ PHPUnit_Framework_Assert::assertEquals( $expected, $got, $desc );
}
public function setupRecorder( $options ) {
<?php
-require_once dirname(dirname(dirname(__FILE__))). '/bootstrap.php';
+require_once dirname(__FILE__) . '/../../bootstrap.php';
/**
* @group Stub
}
function insertSearchData() {
- if ( $this->pageExists( 'Not_Main_Page' ) ) {
+ if ( $this->pageExists( 'Not_Main_Page' ) ) {
return;
- }
- $this->insertPage( "Not_Main_Page", "This is not a main page", 0 );
- $this->insertPage( 'Talk:Not_Main_Page', 'This is not a talk page to the main page, see [[smithee]]', 1 );
- $this->insertPage( 'Smithee', 'A smithee is one who smiths. See also [[Alan Smithee]]', 0 );
- $this->insertPage( 'Talk:Smithee', 'This article sucks.', 1 );
- $this->insertPage( 'Unrelated_page', 'Nothing in this page is about the S word.', 0 );
- $this->insertPage( 'Another_page', 'This page also is unrelated.', 0 );
- $this->insertPage( 'Help:Help', 'Help me!', 4 );
- $this->insertPage( 'Thppt', 'Blah blah', 0 );
- $this->insertPage( 'Alan_Smithee', 'yum', 0 );
- $this->insertPage( 'Pages', 'are\'food', 0 );
- $this->insertPage( 'HalfOneUp', 'AZ', 0 );
- $this->insertPage( 'FullOneUp', 'AZ', 0 );
- $this->insertPage( 'HalfTwoLow', 'az', 0 );
- $this->insertPage( 'FullTwoLow', 'az', 0 );
- $this->insertPage( 'HalfNumbers', '1234567890', 0 );
- $this->insertPage( 'FullNumbers', '1234567890', 0 );
- $this->insertPage( 'DomainName', 'example.com', 0 );
+ }
+ $this->insertPage( "Not_Main_Page", "This is not a main page", 0 );
+ $this->insertPage( 'Talk:Not_Main_Page', 'This is not a talk page to the main page, see [[smithee]]', 1 );
+ $this->insertPage( 'Smithee', 'A smithee is one who smiths. See also [[Alan Smithee]]', 0 );
+ $this->insertPage( 'Talk:Smithee', 'This article sucks.', 1 );
+ $this->insertPage( 'Unrelated_page', 'Nothing in this page is about the S word.', 0 );
+ $this->insertPage( 'Another_page', 'This page also is unrelated.', 0 );
+ $this->insertPage( 'Help:Help', 'Help me!', 4 );
+ $this->insertPage( 'Thppt', 'Blah blah', 0 );
+ $this->insertPage( 'Alan_Smithee', 'yum', 0 );
+ $this->insertPage( 'Pages', 'are\'food', 0 );
+ $this->insertPage( 'HalfOneUp', 'AZ', 0 );
+ $this->insertPage( 'FullOneUp', 'AZ', 0 );
+ $this->insertPage( 'HalfTwoLow', 'az', 0 );
+ $this->insertPage( 'FullTwoLow', 'az', 0 );
+ $this->insertPage( 'HalfNumbers', '1234567890', 0 );
+ $this->insertPage( 'FullNumbers', '1234567890', 0 );
+ $this->insertPage( 'DomainName', 'example.com', 0 );
}
function removeSearchData() {
$article = new Article( $title, $id );
$article->doDeleteArticle( "Search Test" );
}*/
- }
+ }
function fetchIds( $results ) {
$this->assertTrue( is_object( $results ) );
// Modified version of WikiRevision::importOldRevision()
function insertPage( $pageName, $text, $ns ) {
- $dbw = $this->db;
- $title = Title::newFromText( $pageName );
-
- $userId = 0;
- $userText = 'WikiSysop';
- $comment = 'Search Test';
-
- // avoid memory leak...?
- $linkCache = LinkCache::singleton();
- $linkCache->clear();
-
- $article = new Article( $title );
- $pageId = $article->getId();
- $created = false;
- if ( $pageId == 0 ) {
- # must create the page...
- $pageId = $article->insertOn( $dbw );
- $created = true;
- }
-
- # FIXME: Use original rev_id optionally (better for backups)
- # Insert the row
- $revision = new Revision( array(
- 'page' => $pageId,
- 'text' => $text,
- 'comment' => $comment,
- 'user' => $userId,
- 'user_text' => $userText,
- 'timestamp' => 0,
- 'minor_edit' => false,
+ $dbw = $this->db;
+ $title = Title::newFromText( $pageName );
+
+ $userId = 0;
+ $userText = 'WikiSysop';
+ $comment = 'Search Test';
+
+ // avoid memory leak...?
+ $linkCache = LinkCache::singleton();
+ $linkCache->clear();
+
+ $article = new Article( $title );
+ $pageId = $article->getId();
+ $created = false;
+ if ( $pageId == 0 ) {
+ # must create the page...
+ $pageId = $article->insertOn( $dbw );
+ $created = true;
+ }
+
+ # FIXME: Use original rev_id optionally (better for backups)
+ # Insert the row
+ $revision = new Revision( array(
+ 'page' => $pageId,
+ 'text' => $text,
+ 'comment' => $comment,
+ 'user' => $userId,
+ 'user_text' => $userText,
+ 'timestamp' => 0,
+ 'minor_edit' => false,
) );
- $revId = $revision->insertOn( $dbw );
- $changed = $article->updateIfNewerOn( $dbw, $revision );
+ $revId = $revision->insertOn( $dbw );
+ $changed = $article->updateIfNewerOn( $dbw, $revision );
- $GLOBALS['wgTitle'] = $title;
- if ( $created ) {
- Article::onArticleCreate( $title );
- $article->createUpdates( $revision );
- } elseif ( $changed ) {
- Article::onArticleEdit( $title );
- $article->editUpdates(
- $text, $comment, false, 0, $revId );
- }
+ $GLOBALS['wgTitle'] = $title;
+ if ( $created ) {
+ Article::onArticleCreate( $title );
+ $article->createUpdates( $revision );
+ } elseif ( $changed ) {
+ Article::onArticleEdit( $title );
+ $article->editUpdates(
+ $text, $comment, false, 0, $revId );
+ }
- $su = new SearchUpdate( $article->getId(), $pageName, $text );
- $su->doUpdate();
+ $su = new SearchUpdate( $article->getId(), $pageName, $text );
+ $su->doUpdate();
- $this->pageList[] = array( $title, $article->getId() );
+ $this->pageList[] = array( $title, $article->getId() );
- return true;
- }
+ return true;
+ }
function testFullWidth() {
- $this->assertEquals(
- array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
- $this->fetchIds( $this->search->searchText( 'AZ' ) ),
- "Search for normalized from Half-width Upper" );
- $this->assertEquals(
- array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
- $this->fetchIds( $this->search->searchText( 'az' ) ),
- "Search for normalized from Half-width Lower" );
- $this->assertEquals(
- array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
- $this->fetchIds( $this->search->searchText( 'AZ' ) ),
- "Search for normalized from Full-width Upper" );
- $this->assertEquals(
- array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
- $this->fetchIds( $this->search->searchText( 'az' ) ),
- "Search for normalized from Full-width Lower" );
+ $this->assertEquals(
+ array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
+ $this->fetchIds( $this->search->searchText( 'AZ' ) ),
+ "Search for normalized from Half-width Upper" );
+ $this->assertEquals(
+ array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
+ $this->fetchIds( $this->search->searchText( 'az' ) ),
+ "Search for normalized from Half-width Lower" );
+ $this->assertEquals(
+ array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
+ $this->fetchIds( $this->search->searchText( 'AZ' ) ),
+ "Search for normalized from Full-width Upper" );
+ $this->assertEquals(
+ array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
+ $this->fetchIds( $this->search->searchText( 'az' ) ),
+ "Search for normalized from Full-width Lower" );
}
function testTextSearch() {
$this->assertEquals(
- array( 'Smithee' ),
- $this->fetchIds( $this->search->searchText( 'smithee' ) ),
- "Plain search failed" );
+ array( 'Smithee' ),
+ $this->fetchIds( $this->search->searchText( 'smithee' ) ),
+ "Plain search failed" );
}
function testTextPowerSearch() {
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./bootstrap.php"
- colors="false"
+ colors="false"
backupGlobals="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
- stopOnFailure="false"
- strict="true">
+ stopOnFailure="false">
<testsuites>
<testsuite name="includes">
<directory>./includes</directory>
</testsuites>
<groups>
<exclude>
- <group>Utility</group>
<group>Broken</group>
<group>Stub</group>
</exclude>
$this->success = 0;
}
- function record( $test, $result, $recorder ) {
+ function record( $test, $result ) {
$this->total++;
- if( $result ) {
- $recorder->recordTest( $test );
- $this->success += ( $result ? 1 : 0 );
- }
+ $this->success += ( $result ? 1 : 0 );
}
function end() {
}
}
-class DbTestPreviewer extends TestRecorder {
- protected $lb; // /< Database load balancer
- protected $db; // /< Database connection to the main DB
- protected $curRun; // /< run ID number for the current run
+class DbTestPreviewer extends TestRecorder {
+ protected $lb; // /< Database load balancer
+ protected $db; // /< Database connection to the main DB
+ protected $curRun; // /< run ID number for the current run
protected $prevRun; // /< run ID number for the previous run, if any
protected $results; // /< Result array
printf( "\n%4d %s\n", $count, $label );
foreach ( $breakdown[$code] as $differing_test_name => $statusInfo ) {
- print " * $differing_test_name [$statusInfo]\n";
+ print " * $differing_test_name [$statusInfo]\n";
}
}
}
// Otherwise, this test has previous recorded results.
// See when this test last had a different result to what we're seeing now.
$conds = array(
- 'ti_name' => $testname,
+ 'ti_name' => $testname,
'ti_success' => ( $after == 'f' ? "1" : "0" ) );
if ( $this->curRun ) {
}
return ( $after == "f" ? "Introduced" : "Fixed" ) . " between "
- . date( "d-M-Y H:i:s", strtotime ( $pre->tr_date ) ) . ", " . $pre->tr_mw_version
+ . date( "d-M-Y H:i:s", strtotime ( $pre->tr_date ) ) . ", " . $pre->tr_mw_version
. " and $postDate";
}
$this->db->insert( 'testrun',
array(
- 'tr_date' => $this->db->timestamp(),
- 'tr_mw_version' => $this->version,
+ 'tr_date' => $this->db->timestamp(),
+ 'tr_mw_version' => $this->version,
'tr_php_version' => phpversion(),
- 'tr_db_version' => $this->db->getServerVersion(),
- 'tr_uname' => php_uname()
+ 'tr_db_version' => $this->db->getServerVersion(),
+ 'tr_uname' => php_uname()
),
__METHOD__ );
if ( $wgDBtype === 'postgres' ) {
$this->db->insert( 'testitem',
array(
- 'ti_run' => $this->curRun,
- 'ti_name' => $test,
+ 'ti_run' => $this->curRun,
+ 'ti_name' => $test,
'ti_success' => $result ? 1 : 0,
),
__METHOD__ );
* Inform a CodeReview instance that we've started or completed a test run...
*
* @param $status string: "running" - tell it we've started
- * "complete" - provide test results array
- * "abort" - something went horribly awry
+ * "complete" - provide test results array
+ * "abort" - something went horribly awry
* @param $results array of test name => true/false
*/
function ping( $status, $results = false ) {
$postData = array(
'action' => 'codetestupload',
'format' => 'json',
- 'repo' => $remote['repo'],
- 'suite' => $remote['suite'],
- 'rev' => $revId,
+ 'repo' => $remote['repo'],
+ 'suite' => $remote['suite'],
+ 'rev' => $revId,
'status' => $status,
- 'hmac' => $hmac,
+ 'hmac' => $hmac,
);
if ( $status == "complete" ) {
$this->lineNum = $this->index = 0;
}
- function setParser( MediaWikiParserTest $parser ) {
+ function setParser( ParserTest $parser ) {
$this->parser = $parser;
}