Index: trunk/phase3/maintenance/tests/DatabaseSqliteTest.php |
— | — | @@ -54,4 +54,31 @@ |
55 | 55 | $this->replaceVars( "ALTER TABLE foo\nADD COLUMN foo_bar int(10) unsigned DEFAULT 42" ) |
56 | 56 | ); |
57 | 57 | } |
| 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 | + } |
58 | 85 | } |
\ No newline at end of file |