http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90126

Revision: 90126
Author:   maxsem
Date:     2011-06-15 17:59:02 +0000 (Wed, 15 Jun 2011)
Log Message:
-----------
Also check indexes in SQLite upgrade tests

Modified Paths:
--------------
    trunk/phase3/tests/phpunit/includes/db/DatabaseSqliteTest.php

Modified: trunk/phase3/tests/phpunit/includes/db/DatabaseSqliteTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/db/DatabaseSqliteTest.php       
2011-06-15 17:57:00 UTC (rev 90125)
+++ trunk/phase3/tests/phpunit/includes/db/DatabaseSqliteTest.php       
2011-06-15 17:59:02 UTC (rev 90126)
@@ -174,7 +174,7 @@
                                $this->assertEquals(
                                        array_keys( $currentCols ),
                                        array_keys( $cols ),
-                                       "Mismatching columns for table $table 
$versions"
+                                       "Mismatching columns for table 
\"$table\" $versions"
                                );
                                foreach ( $currentCols as $name => $column ) {
                                        $fullName = "$table.$name";
@@ -196,6 +196,13 @@
                                                );
                                        }
                                }
+                               $currentIndexes = $this->getIndexes( 
$currentDB, $table );
+                               $indexes = $this->getIndexes( $db, $table );
+                               $this->assertEquals(
+                                       array_keys( $currentIndexes ),
+                                       array_keys( $indexes ),
+                                       "mismatching indexes for table 
\"$table\" $versions"
+                               );
                        }
                        $db->close();
                }
@@ -245,4 +252,21 @@
                ksort( $cols );
                return $cols;
        }
+
+       private function getIndexes( $db, $table ) {
+               $indexes = array();
+               $res = $db->query( "PRAGMA index_list($table)" );
+               $this->assertNotNull( $res );
+               foreach ( $res as $index ) {
+                       $res2 = $db->query( "PRAGMA index_info({$index->name})" 
);
+                       $this->assertNotNull( $res2 );
+                       $index->columns = array();
+                       foreach ( $res2 as $col ) {
+                               $index->columns[] = $col;
+                       }
+                       $indexes[$index->name] = $index;
+               }
+               ksort( $indexes );
+               return $indexes;
+       }
 }


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to