From: Max Semenik Date: Tue, 25 May 2010 17:32:18 +0000 (+0000) Subject: New test for SQLite that checks tables.sql conversion as a whole X-Git-Tag: 1.31.0-rc.0~36729 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=aa7a5ecea00f1853bcf4b95fe7ca0a21c27101b0;p=lhc%2Fweb%2Fwiklou.git New test for SQLite that checks tables.sql conversion as a whole --- diff --git a/maintenance/tests/DatabaseSqliteTest.php b/maintenance/tests/DatabaseSqliteTest.php index 6ca0976056..69d4cb1d51 100644 --- a/maintenance/tests/DatabaseSqliteTest.php +++ b/maintenance/tests/DatabaseSqliteTest.php @@ -54,4 +54,31 @@ class DatabaseSqliteTest extends PHPUnit_Framework_TestCase { $this->replaceVars( "ALTER TABLE foo\nADD COLUMN foo_bar int(10) unsigned DEFAULT 42" ) ); } + + function testEntireSchema() { + global $IP; + + $allowedTypes = array_flip( array( + 'integer', + 'real', + 'text', + 'blob', // NULL type is omitted intentionally + ) ); + + $db = new DatabaseSqliteStandalone( ':memory:' ); + $db->sourceFile( "$IP/maintenance/tables.sql" ); + + $tables = $db->query( "SELECT name FROM sqlite_master WHERE type='table'", __METHOD__ ); + foreach ( $tables as $table ) { + if ( strpos( $table->name, 'sqlite_' ) === 0 ) continue; + + $columns = $db->query( "PRAGMA table_info({$table->name})", __METHOD__ ); + foreach ( $columns as $col ) { + if ( !isset( $allowedTypes[strtolower( $col->type )] ) ) { + $this->fail( "Table {$table->name} has column {$col->name} with non-native type '{$col->type}'" ); + } + } + } + $db->close(); + } } \ No newline at end of file