Index: trunk/phase3/tests/phpunit/MediaWikiTestCase.php |
— | — | @@ -9,6 +9,12 @@ |
10 | 10 | protected $dbClone; |
11 | 11 | protected $oldTablePrefix; |
12 | 12 | 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_'; |
13 | 19 | |
14 | 20 | protected $supportedDBs = array( |
15 | 21 | 'mysql', |
— | — | @@ -66,7 +72,11 @@ |
67 | 73 | $rc = new ReflectionClass( $this ); |
68 | 74 | return strpos( $rc->getDocComment(), '@group Database' ) !== false; |
69 | 75 | } |
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 | + */ |
71 | 81 | function addDBData() {} |
72 | 82 | |
73 | 83 | private function addCoreDBData() { |
— | — | @@ -98,13 +108,13 @@ |
99 | 109 | |
100 | 110 | $dbType = $this->db->getType(); |
101 | 111 | |
102 | | - if ( $wgDBprefix === 'unittest_' || ( $dbType == 'oracle' && $wgDBprefix === 'ut_' ) ) { |
| 112 | + if ( $wgDBprefix === self::DB_PREFIX || ( $dbType == 'oracle' && $wgDBprefix === self::ORA_DB_PREFIX ) ) { |
103 | 113 | throw new MWException( 'Cannot run unit tests, the database prefix is already "unittest_"' ); |
104 | 114 | } |
105 | 115 | |
106 | 116 | $tables = $this->listTables(); |
107 | 117 | |
108 | | - $prefix = $dbType != 'oracle' ? 'unittest_' : 'ut_'; |
| 118 | + $prefix = $dbType != 'oracle' ? self::DB_PREFIX : self::ORA_DB_PREFIX; |
109 | 119 | |
110 | 120 | $this->dbClone = new CloneDatabase( $this->db, $tables, $prefix ); |
111 | 121 | $this->dbClone->useTemporaryTables( false ); //reported problems with temp tables, disabling until fixed |
— | — | @@ -137,10 +147,10 @@ |
138 | 148 | } |
139 | 149 | |
140 | 150 | if( $this->db->getType() == 'oracle' ) { |
141 | | - $tables = $this->db->listTables( 'ut_', __METHOD__ ); |
| 151 | + $tables = $this->db->listTables( self::ORA_DB_PREFIX, __METHOD__ ); |
142 | 152 | } |
143 | 153 | else { |
144 | | - $tables = $this->db->listTables( 'unittest_', __METHOD__ ); |
| 154 | + $tables = $this->db->listTables( self::DB_PREFIX, __METHOD__ ); |
145 | 155 | } |
146 | 156 | |
147 | 157 | foreach ( $tables as $table ) { |