Add classes to tag markers on recentchanges
[lhc/web/wiklou.git] / tests / MediaWiki_TestCase.php
1 <?php
2
3 abstract class MediaWiki_TestCase extends PHPUnit_Framework_TestCase {
4 /**
5 * @param string $serverType
6 * @param array $tables
7 */
8 protected function buildTestDatabase( $tables ) {
9 global $testOptions, $wgDBprefix, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname;
10 $wgDBprefix = 'parsertest_';
11 $db = new DatabaseMysql(
12 $wgDBserver,
13 $wgDBadminuser,
14 $wgDBadminpassword,
15 $wgDBname );
16 if( $db->isOpen() ) {
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];
22 $tableName = $tbl;
23 $db->query("CREATE TEMPORARY TABLE $newTableName (LIKE $tableName)");
24 }
25 } else {
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);
33 $create = $row[1];
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" );
39 }
40 $db->query($create_tmp);
41 }
42
43 }
44 return $db;
45 } else {
46 // Something amiss
47 return null;
48 }
49 }
50 }
51