r79944 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79943‎ | r79944 | r79945 >
Date:18:34, 10 January 2011
Author:demon
Status:ok
Tags:
Comment:
Move table prefixes to constants, add doc to addDBData()
Modified paths:
  • /trunk/phase3/tests/phpunit/MediaWikiTestCase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/MediaWikiTestCase.php
@@ -9,6 +9,12 @@
1010 protected $dbClone;
1111 protected $oldTablePrefix;
1212 protected $useTemporaryTables = true;
 13+
 14+ /**
 15+ * Table name prefixes. Oracle likes it shorter.
 16+ */
 17+ const DB_PREFIX = 'unittest_';
 18+ const ORA_DB_PREFIX = 'ut_';
1319
1420 protected $supportedDBs = array(
1521 'mysql',
@@ -66,7 +72,11 @@
6773 $rc = new ReflectionClass( $this );
6874 return strpos( $rc->getDocComment(), '@group Database' ) !== false;
6975 }
70 -
 76+
 77+ /**
 78+ * Stub. If a test needs to add additional data to the database, it should
 79+ * implement this method and do so
 80+ */
7181 function addDBData() {}
7282
7383 private function addCoreDBData() {
@@ -98,13 +108,13 @@
99109
100110 $dbType = $this->db->getType();
101111
102 - if ( $wgDBprefix === 'unittest_' || ( $dbType == 'oracle' && $wgDBprefix === 'ut_' ) ) {
 112+ if ( $wgDBprefix === self::DB_PREFIX || ( $dbType == 'oracle' && $wgDBprefix === self::ORA_DB_PREFIX ) ) {
103113 throw new MWException( 'Cannot run unit tests, the database prefix is already "unittest_"' );
104114 }
105115
106116 $tables = $this->listTables();
107117
108 - $prefix = $dbType != 'oracle' ? 'unittest_' : 'ut_';
 118+ $prefix = $dbType != 'oracle' ? self::DB_PREFIX : self::ORA_DB_PREFIX;
109119
110120 $this->dbClone = new CloneDatabase( $this->db, $tables, $prefix );
111121 $this->dbClone->useTemporaryTables( false ); //reported problems with temp tables, disabling until fixed
@@ -137,10 +147,10 @@
138148 }
139149
140150 if( $this->db->getType() == 'oracle' ) {
141 - $tables = $this->db->listTables( 'ut_', __METHOD__ );
 151+ $tables = $this->db->listTables( self::ORA_DB_PREFIX, __METHOD__ );
142152 }
143153 else {
144 - $tables = $this->db->listTables( 'unittest_', __METHOD__ );
 154+ $tables = $this->db->listTables( self::DB_PREFIX, __METHOD__ );
145155 }
146156
147157 foreach ( $tables as $table ) {

Status & tagging log