r66881 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66880‎ | r66881 | r66882 >
Date:17:32, 25 May 2010
Author:maxsem
Status:ok
Tags:
Comment:
New test for SQLite that checks tables.sql conversion as a whole
Modified paths:
  • /trunk/phase3/maintenance/tests/DatabaseSqliteTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/DatabaseSqliteTest.php
@@ -54,4 +54,31 @@
5555 $this->replaceVars( "ALTER TABLE foo\nADD COLUMN foo_bar int(10) unsigned DEFAULT 42" )
5656 );
5757 }
 58+
 59+ function testEntireSchema() {
 60+ global $IP;
 61+
 62+ $allowedTypes = array_flip( array(
 63+ 'integer',
 64+ 'real',
 65+ 'text',
 66+ 'blob', // NULL type is omitted intentionally
 67+ ) );
 68+
 69+ $db = new DatabaseSqliteStandalone( ':memory:' );
 70+ $db->sourceFile( "$IP/maintenance/tables.sql" );
 71+
 72+ $tables = $db->query( "SELECT name FROM sqlite_master WHERE type='table'", __METHOD__ );
 73+ foreach ( $tables as $table ) {
 74+ if ( strpos( $table->name, 'sqlite_' ) === 0 ) continue;
 75+
 76+ $columns = $db->query( "PRAGMA table_info({$table->name})", __METHOD__ );
 77+ foreach ( $columns as $col ) {
 78+ if ( !isset( $allowedTypes[strtolower( $col->type )] ) ) {
 79+ $this->fail( "Table {$table->name} has column {$col->name} with non-native type '{$col->type}'" );
 80+ }
 81+ }
 82+ }
 83+ $db->close();
 84+ }
5885 }
\ No newline at end of file

Status & tagging log