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 $wgDBprefix = 'parsertest';
17 if (!(strcmp($db->getServerVersion(), '4.1') < 0 and stristr($db->getSoftwareLink(), 'MySQL'))) {
18 # Database that supports CREATE TABLE ... LIKE
19 foreach ($tables as $tbl) {
20 $newTableName = $db->tableName( $tbl );
21 #$tableName = $this->oldTableNames[$tbl];
23 $db->query("CREATE TEMPORARY TABLE $newTableName (LIKE $tableName)");
26 # Hack for MySQL versions < 4.1, which don't support
27 # "CREATE TABLE ... LIKE". Note that
28 # "CREATE TEMPORARY TABLE ... SELECT * FROM ... LIMIT 0"
29 # would not create the indexes we need....
30 foreach ($tables as $tbl) {
31 $res = $db->query("SHOW CREATE TABLE $tbl");
32 $row = $db->fetchRow($res);
34 $create_tmp = preg_replace('/CREATE TABLE `(.*?)`/', 'CREATE TEMPORARY TABLE `'
35 . $wgDBprefix . '\\1`', $create);
36 if ($create === $create_tmp) {
37 # Couldn't do replacement
38 wfDie( "could not create temporary table $tbl" );
40 $db->query($create_tmp);