From 8296d0736b546ead9e64858e68c41453adf1b918 Mon Sep 17 00:00:00 2001 From: OverlordQ Date: Mon, 24 Oct 2011 19:28:31 +0000 Subject: [PATCH] Basic support for Postgres phpunit testing, currently throws 5 errors, 1 inc, 5 skipped --- includes/db/DatabasePostgres.php | 18 ++++++++++++++++++ tests/phpunit/MediaWikiTestCase.php | 1 + 2 files changed, 19 insertions(+) diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 8974dc8990..04c70e6d51 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -688,6 +688,24 @@ class DatabasePostgres extends DatabaseBase { return $this->query( 'CREATE ' . ( $temporary ? 'TEMPORARY ' : '' ) . " TABLE $newName (LIKE $oldName INCLUDING DEFAULTS)", $fname ); } + function listTables( $prefix = null, $fname = 'DatabasePostgres::listTables' ) { + global $wgDBmwschema; + $eschema = $this->addQuotes( $wgDBmwschema ); + $result = $this->query( "SELECT tablename FROM pg_tables WHERE schemaname = $eschema", $fname ); + + $endArray = array(); + + foreach( $result as $table ) { + $vars = get_object_vars($table); + $table = array_pop( $vars ); + if( !$prefix || strpos( $table, $prefix ) === 0 ) { + $endArray[] = $table; + } + } + + return $endArray; + } + function timestamp( $ts = 0 ) { return wfTimestamp( TS_POSTGRES, $ts ); } diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index fb6baf68fc..7a64fab9be 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -22,6 +22,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { protected $supportedDBs = array( 'mysql', 'sqlite', + 'postgres', 'oracle' ); -- 2.20.1