r83291 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83290‎ | r83291 | r83292 >
Date:15:44, 5 March 2011
Author:maxsem
Status:ok
Tags:
Comment:
MediaWikiTestCase: factored prefix generation to a separate function
Modified paths:
  • /trunk/phase3/tests/phpunit/MediaWikiTestCase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/MediaWikiTestCase.php
@@ -69,6 +69,10 @@
7070 $this->destroyDB();
7171 }
7272 }
 73+
 74+ function dbPrefix() {
 75+ return $this->db->getType() == 'oracle' ? self::ORA_DB_PREFIX : self::DB_PREFIX;
 76+ }
7377
7478 function needsDB() {
7579 $rc = new ReflectionClass( $this );
@@ -112,15 +116,13 @@
113117
114118 $dbType = $this->db->getType();
115119
116 - if ( $wgDBprefix === self::DB_PREFIX || ( $dbType == 'oracle' && $wgDBprefix === self::ORA_DB_PREFIX ) ) {
 120+ if ( $wgDBprefix === $this->dbPrefix() ) {
117121 throw new MWException( 'Cannot run unit tests, the database prefix is already "unittest_"' );
118122 }
119123
120124 $tables = $this->listTables();
121125
122 - $prefix = $dbType != 'oracle' ? self::DB_PREFIX : self::ORA_DB_PREFIX;
123 -
124 - $this->dbClone = new CloneDatabase( $this->db, $tables, $prefix );
 126+ $this->dbClone = new CloneDatabase( $this->db, $tables, $this->dbPrefix() );
125127 $this->dbClone->useTemporaryTables( $this->useTemporaryTables );
126128 $this->dbClone->cloneTableStructure();
127129
@@ -150,12 +152,7 @@
151153 return;
152154 }
153155
154 - if( $this->db->getType() == 'oracle' ) {
155 - $tables = $this->db->listTables( self::ORA_DB_PREFIX, __METHOD__ );
156 - }
157 - else {
158 - $tables = $this->db->listTables( self::DB_PREFIX, __METHOD__ );
159 - }
 156+ $tables = $this->db->listTables( $this->dbPrefix(), __METHOD__ );
160157
161158 foreach ( $tables as $table ) {
162159 try {

Status & tagging log