r90126 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90125‎ | r90126 | r90127 >
Date:17:59, 15 June 2011
Author:maxsem
Status:ok
Tags:
Comment:
Also check indexes in SQLite upgrade tests
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/db/DatabaseSqliteTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/db/DatabaseSqliteTest.php
@@ -174,7 +174,7 @@
175175 $this->assertEquals(
176176 array_keys( $currentCols ),
177177 array_keys( $cols ),
178 - "Mismatching columns for table $table $versions"
 178+ "Mismatching columns for table \"$table\" $versions"
179179 );
180180 foreach ( $currentCols as $name => $column ) {
181181 $fullName = "$table.$name";
@@ -196,6 +196,13 @@
197197 );
198198 }
199199 }
 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+ );
200207 }
201208 $db->close();
202209 }
@@ -245,4 +252,21 @@
246253 ksort( $cols );
247254 return $cols;
248255 }
 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+ }
249273 }

Status & tagging log