From: Max Semenik Date: Sat, 5 Mar 2011 15:44:28 +0000 (+0000) Subject: MediaWikiTestCase: factored prefix generation to a separate function X-Git-Tag: 1.31.0-rc.0~31635 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=332d709d8b52adf7e5221051f5c3f16e15e151ae;p=lhc%2Fweb%2Fwiklou.git MediaWikiTestCase: factored prefix generation to a separate function --- diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index c030c4d6cf..4119482783 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -69,6 +69,10 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { $this->destroyDB(); } } + + function dbPrefix() { + return $this->db->getType() == 'oracle' ? self::ORA_DB_PREFIX : self::DB_PREFIX; + } function needsDB() { $rc = new ReflectionClass( $this ); @@ -112,15 +116,13 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { $dbType = $this->db->getType(); - if ( $wgDBprefix === self::DB_PREFIX || ( $dbType == 'oracle' && $wgDBprefix === self::ORA_DB_PREFIX ) ) { + if ( $wgDBprefix === $this->dbPrefix() ) { throw new MWException( 'Cannot run unit tests, the database prefix is already "unittest_"' ); } $tables = $this->listTables(); - $prefix = $dbType != 'oracle' ? self::DB_PREFIX : self::ORA_DB_PREFIX; - - $this->dbClone = new CloneDatabase( $this->db, $tables, $prefix ); + $this->dbClone = new CloneDatabase( $this->db, $tables, $this->dbPrefix() ); $this->dbClone->useTemporaryTables( $this->useTemporaryTables ); $this->dbClone->cloneTableStructure(); @@ -150,12 +152,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { return; } - if( $this->db->getType() == 'oracle' ) { - $tables = $this->db->listTables( self::ORA_DB_PREFIX, __METHOD__ ); - } - else { - $tables = $this->db->listTables( self::DB_PREFIX, __METHOD__ ); - } + $tables = $this->db->listTables( $this->dbPrefix(), __METHOD__ ); foreach ( $tables as $table ) { try {