2 error_reporting( E_ALL
);
3 define( "MEDIAWIKI", true );
5 require_once( 'PHPUnit.php' );
18 'postgresql' => array(
25 if( file_exists( 'LocalTestSettings.php' ) ) {
26 include( './LocalTestSettings.php' );
35 foreach( $tests as $test ) {
36 require_once( $test . '.php' );
37 $suite = new PHPUnit_TestSuite( $test );
38 $result = PHPUnit
::run( $suite );
39 echo $result->toString();
43 * @param string $serverType
44 * @param array $tables
46 function &buildTestDatabase( $serverType, $tables ) {
47 global $testOptions, $wgDBprefix;
48 $wgDBprefix = 'parsertest';
50 $testOptions[$serverType]['server'],
51 $testOptions[$serverType]['user'],
52 $testOptions[$serverType]['password'],
53 $testOptions[$serverType]['database'] );
55 if (!(strcmp($db->getServerVersion(), '4.1') < 0 and stristr($db->getSoftwareLink(), 'MySQL'))) {
56 # Database that supports CREATE TABLE ... LIKE
57 foreach ($tables as $tbl) {
58 $newTableName = $db->tableName( $tbl );
59 #$tableName = $this->oldTableNames[$tbl];
61 $db->query("CREATE TEMPORARY TABLE $newTableName (LIKE $tableName INCLUDING DEFAULTS)");
64 # Hack for MySQL versions < 4.1, which don't support
65 # "CREATE TABLE ... LIKE". Note that
66 # "CREATE TEMPORARY TABLE ... SELECT * FROM ... LIMIT 0"
67 # would not create the indexes we need....
68 foreach ($tables as $tbl) {
69 $res = $db->query("SHOW CREATE TABLE $tbl");
70 $row = $db->fetchRow($res);
72 $create_tmp = preg_replace('/CREATE TABLE `(.*?)`/', 'CREATE TEMPORARY TABLE `'
73 . $wgDBprefix . '\\1`', $create);
74 if ($create === $create_tmp) {
75 # Couldn't do replacement
76 die("could not create temporary table $tbl");
78 $db->query($create_tmp);