3 abstract class MediaWiki_TestCase
extends PHPUnit_Framework_TestCase
{
5 * @param string $serverType
8 protected function buildTestDatabase( $tables ) {
9 global $testOptions, $wgDBprefix, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname;
10 $this->markTestIncomplete("This test requires DB admin user credentials.");
11 $wgDBprefix = 'parsertest_';
13 $db = new DatabaseMysql(
19 if (!(strcmp($db->getServerVersion(), '4.1') < 0 and stristr($db->getSoftwareLink(), 'MySQL'))) {
20 # Database that supports CREATE TABLE ... LIKE
21 foreach ($tables as $tbl) {
22 $newTableName = $db->tableName( $tbl );
23 #$tableName = $this->oldTableNames[$tbl];
25 $db->query("CREATE TEMPORARY TABLE $newTableName (LIKE $tableName)");
28 # Hack for MySQL versions < 4.1, which don't support
29 # "CREATE TABLE ... LIKE". Note that
30 # "CREATE TEMPORARY TABLE ... SELECT * FROM ... LIMIT 0"
31 # would not create the indexes we need....
32 foreach ($tables as $tbl) {
33 $res = $db->query("SHOW CREATE TABLE $tbl");
34 $row = $db->fetchRow($res);
36 $create_tmp = preg_replace('/CREATE TABLE `(.*?)`/', 'CREATE TEMPORARY TABLE `'
37 . $wgDBprefix . '\\1`', $create);
38 if ($create === $create_tmp) {
39 # Couldn't do replacement
40 wfDie( "could not create temporary table $tbl" );
42 $db->query($create_tmp);