Index: trunk/phase3/tests/phpunit/includes/db/DatabaseSqliteTest.php |
— | — | @@ -174,7 +174,7 @@ |
175 | 175 | $this->assertEquals( |
176 | 176 | array_keys( $currentCols ), |
177 | 177 | array_keys( $cols ), |
178 | | - "Mismatching columns for table $table $versions" |
| 178 | + "Mismatching columns for table \"$table\" $versions" |
179 | 179 | ); |
180 | 180 | foreach ( $currentCols as $name => $column ) { |
181 | 181 | $fullName = "$table.$name"; |
— | — | @@ -196,6 +196,13 @@ |
197 | 197 | ); |
198 | 198 | } |
199 | 199 | } |
| 200 | + $currentIndexes = $this->getIndexes( $currentDB, $table ); |
| 201 | + $indexes = $this->getIndexes( $db, $table ); |
| 202 | + $this->assertEquals( |
| 203 | + array_keys( $currentIndexes ), |
| 204 | + array_keys( $indexes ), |
| 205 | + "mismatching indexes for table \"$table\" $versions" |
| 206 | + ); |
200 | 207 | } |
201 | 208 | $db->close(); |
202 | 209 | } |
— | — | @@ -245,4 +252,21 @@ |
246 | 253 | ksort( $cols ); |
247 | 254 | return $cols; |
248 | 255 | } |
| 256 | + |
| 257 | + private function getIndexes( $db, $table ) { |
| 258 | + $indexes = array(); |
| 259 | + $res = $db->query( "PRAGMA index_list($table)" ); |
| 260 | + $this->assertNotNull( $res ); |
| 261 | + foreach ( $res as $index ) { |
| 262 | + $res2 = $db->query( "PRAGMA index_info({$index->name})" ); |
| 263 | + $this->assertNotNull( $res2 ); |
| 264 | + $index->columns = array(); |
| 265 | + foreach ( $res2 as $col ) { |
| 266 | + $index->columns[] = $col; |
| 267 | + } |
| 268 | + $indexes[$index->name] = $index; |
| 269 | + } |
| 270 | + ksort( $indexes ); |
| 271 | + return $indexes; |
| 272 | + } |
249 | 273 | } |