<?php
abstract class MediaWiki_Setup extends PHPUnit_Framework_TestCase {
- /**
- * @param string $serverType
- * @param array $tables
- */
+
protected function buildTestDatabase( $tables ) {
- global $testOptions, $wgDBprefix, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname;
- $this->markTestIncomplete("This test requires DB admin user credentials.");
- $wgDBprefix = 'parsertest_';
+ global $wgDBprefix;
+
+ $db = wfGetDB( DB_MASTER );
+ $oldTableNames = array();
+ foreach( $tables as $table )
+ $oldTableNames[$table] = $db->tableName( $table );
+ $db->tablePrefix( 'parsertest_' );
- $db = new DatabaseMysql(
- $wgDBserver,
- $wgDBadminuser,
- $wgDBadminpassword,
- $wgDBname );
if( $db->isOpen() ) {
- if (!(strcmp($db->getServerVersion(), '4.1') < 0 and stristr($db->getSoftwareLink(), 'MySQL'))) {
+ if ( !( strcmp( $db->getServerVersion(), '4.1' ) < 0 and $db->getType() == 'mysql' ) ) {
# Database that supports CREATE TABLE ... LIKE
- foreach ($tables as $tbl) {
+ foreach ( $tables as $tbl ) {
$newTableName = $db->tableName( $tbl );
- #$tableName = $this->oldTableNames[$tbl];
- $tableName = $tbl;
- $db->query("CREATE TEMPORARY TABLE $newTableName (LIKE $tableName)");
+ $tableName = $oldTableNames[$tbl];
+ $db->query( "CREATE TEMPORARY TABLE $newTableName (LIKE $tableName)" );
}
} else {
# Hack for MySQL versions < 4.1, which don't support
# "CREATE TABLE ... LIKE". Note that
# "CREATE TEMPORARY TABLE ... SELECT * FROM ... LIMIT 0"
# would not create the indexes we need....
- foreach ($tables as $tbl) {
- $res = $db->query("SHOW CREATE TABLE $tbl");
+ foreach ( $tables as $tbl ) {
+ $res = $db->query( "SHOW CREATE TABLE $tbl" );
$row = $db->fetchRow($res);
$create = $row[1];
- $create_tmp = preg_replace('/CREATE TABLE `(.*?)`/', 'CREATE TEMPORARY TABLE `'
- . $wgDBprefix . '\\1`', $create);
+ $create_tmp = preg_replace( '/CREATE TABLE `(.*?)`/', 'CREATE TEMPORARY TABLE `'
+ . $wgDBprefix . '\\1`', $create );
if ($create === $create_tmp) {
# Couldn't do replacement
wfDie( "could not create temporary table $tbl" );
}
- $db->query($create_tmp);
+ $db->query( $create_tmp );
}
}
* @file
*/
-global $wgCommandLineMode, $IP;
-$wgCommandLineMode = true;
+global $wgCommandLineMode, $IP, $optionsWithArgs;
$IP = dirname( dirname( dirname( __FILE__ ) ) );
-
-define( 'MEDIAWIKI', true );
define( 'MW_PHPUNIT_TEST', true );
-require_once( "$IP/includes/Defines.php" );
-require_once( "$IP/includes/AutoLoader.php" );
-require_once( "$IP/LocalSettings.php" );
-require_once( "$IP/includes/ProfilerStub.php" );
-require_once( "$IP/includes/GlobalFunctions.php" );
-require_once( "$IP/includes/Hooks.php" );
-$self = __FILE__;
-require_once( "$IP/includes/Setup.php" );
-
+require_once( "$IP/maintenance/commandLine.inc" );