r62089 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62088‎ | r62089 | r62090 >
Date:16:42, 7 February 2010
Author:ialex
Status:resolved (Comments)
Tags:
Comment:
* Modified MediaWiki_Setup to use the normal mechanism to get a database connection
* Include commandLine.inc from bootstrap.php to get admin credentials
* Marked SearchEngineTest as stub and exclude it
Modified paths:
  • /trunk/phase3/maintenance/tests/MediaWiki_Setup.php (modified) (history)
  • /trunk/phase3/maintenance/tests/SearchEngineTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/SearchMySQL4Test.php (modified) (history)
  • /trunk/phase3/maintenance/tests/bootstrap.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit.xml (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/SearchEngineTest.php
@@ -2,9 +2,9 @@
33
44 require_once( 'MediaWiki_Setup.php' );
55
6 -/** @todo document
 6+/**
 7+ * @group Stub
78 */
8 -
99 class SearchEngineTest extends MediaWiki_Setup {
1010 var $db, $search;
1111
Index: trunk/phase3/maintenance/tests/phpunit.xml
@@ -11,6 +11,7 @@
1212 <groups>
1313 <exclude>
1414 <group>Broken</group>
 15+ <group>Stub</group>
1516 </exclude>
1617 </groups>
1718 </phpunit>
\ No newline at end of file
Index: trunk/phase3/maintenance/tests/bootstrap.php
@@ -7,20 +7,9 @@
88 * @file
99 */
1010
11 -global $wgCommandLineMode, $IP;
12 -$wgCommandLineMode = true;
 11+global $wgCommandLineMode, $IP, $optionsWithArgs;
1312 $IP = dirname( dirname( dirname( __FILE__ ) ) );
14 -
15 -define( 'MEDIAWIKI', true );
1613 define( 'MW_PHPUNIT_TEST', true );
1714
18 -require_once( "$IP/includes/Defines.php" );
19 -require_once( "$IP/includes/AutoLoader.php" );
20 -require_once( "$IP/LocalSettings.php" );
21 -require_once( "$IP/includes/ProfilerStub.php" );
22 -require_once( "$IP/includes/GlobalFunctions.php" );
23 -require_once( "$IP/includes/Hooks.php" );
24 -$self = __FILE__;
25 -require_once( "$IP/includes/Setup.php" );
 15+require_once( "$IP/maintenance/commandLine.inc" );
2616
27 -
Index: trunk/phase3/maintenance/tests/SearchMySQL4Test.php
@@ -16,7 +16,7 @@
1717
1818 function tearDown() {
1919 if( !is_null( $this->db ) ) {
20 - $this->db->close();
 20+ wfGetLB()->closeConnecton( $this->db );
2121 }
2222 unset( $this->db );
2323 unset( $this->search );
Index: trunk/phase3/maintenance/tests/MediaWiki_Setup.php
@@ -1,45 +1,40 @@
22 <?php
33
44 abstract class MediaWiki_Setup extends PHPUnit_Framework_TestCase {
5 - /**
6 - * @param string $serverType
7 - * @param array $tables
8 - */
 5+
96 protected function buildTestDatabase( $tables ) {
10 - global $testOptions, $wgDBprefix, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname;
11 - $this->markTestIncomplete("This test requires DB admin user credentials.");
12 - $wgDBprefix = 'parsertest_';
 7+ global $wgDBprefix;
138
14 - $db = new DatabaseMysql(
15 - $wgDBserver,
16 - $wgDBadminuser,
17 - $wgDBadminpassword,
18 - $wgDBname );
 9+ $db = wfGetDB( DB_MASTER );
 10+ $oldTableNames = array();
 11+ foreach( $tables as $table )
 12+ $oldTableNames[$table] = $db->tableName( $table );
 13+ $db->tablePrefix( 'parsertest_' );
 14+
1915 if( $db->isOpen() ) {
20 - if (!(strcmp($db->getServerVersion(), '4.1') < 0 and stristr($db->getSoftwareLink(), 'MySQL'))) {
 16+ if ( !( strcmp( $db->getServerVersion(), '4.1' ) < 0 and $db->getType() == 'mysql' ) ) {
2117 # Database that supports CREATE TABLE ... LIKE
22 - foreach ($tables as $tbl) {
 18+ foreach ( $tables as $tbl ) {
2319 $newTableName = $db->tableName( $tbl );
24 - #$tableName = $this->oldTableNames[$tbl];
25 - $tableName = $tbl;
26 - $db->query("CREATE TEMPORARY TABLE $newTableName (LIKE $tableName)");
 20+ $tableName = $oldTableNames[$tbl];
 21+ $db->query( "CREATE TEMPORARY TABLE $newTableName (LIKE $tableName)" );
2722 }
2823 } else {
2924 # Hack for MySQL versions < 4.1, which don't support
3025 # "CREATE TABLE ... LIKE". Note that
3126 # "CREATE TEMPORARY TABLE ... SELECT * FROM ... LIMIT 0"
3227 # would not create the indexes we need....
33 - foreach ($tables as $tbl) {
34 - $res = $db->query("SHOW CREATE TABLE $tbl");
 28+ foreach ( $tables as $tbl ) {
 29+ $res = $db->query( "SHOW CREATE TABLE $tbl" );
3530 $row = $db->fetchRow($res);
3631 $create = $row[1];
37 - $create_tmp = preg_replace('/CREATE TABLE `(.*?)`/', 'CREATE TEMPORARY TABLE `'
38 - . $wgDBprefix . '\\1`', $create);
 32+ $create_tmp = preg_replace( '/CREATE TABLE `(.*?)`/', 'CREATE TEMPORARY TABLE `'
 33+ . $wgDBprefix . '\\1`', $create );
3934 if ($create === $create_tmp) {
4035 # Couldn't do replacement
4136 wfDie( "could not create temporary table $tbl" );
4237 }
43 - $db->query($create_tmp);
 38+ $db->query( $create_tmp );
4439 }
4540
4641 }

Comments

#Comment by 😂 (talk | contribs)   14:12, 8 February 2010

Getting SQL errors about not having unique table/alias after applying this rev. See User:^demon/Testing_tests#phpunit_output.

#Comment by MarkAHershberger (talk | contribs)   02:54, 26 February 2010

fixed in r62948

Status & tagging log