Brent Garber has uploaded a new change for review.
https://gerrit.wikimedia.org/r/58422
Change subject: Fix PHPUnit ORM Tests to work with Postgres
......................................................................
Fix PHPUnit ORM Tests to work with Postgres
Change-Id: Ia4321727f6f1eab65c91d9876f87d51b545a72c2
---
M tests/phpunit/includes/db/TestORMRowTest.php
1 file changed, 32 insertions(+), 14 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/22/58422/1
diff --git a/tests/phpunit/includes/db/TestORMRowTest.php
b/tests/phpunit/includes/db/TestORMRowTest.php
index 263553a..070673b 100644
--- a/tests/phpunit/includes/db/TestORMRowTest.php
+++ b/tests/phpunit/includes/db/TestORMRowTest.php
@@ -64,23 +64,40 @@
$dbw = wfGetDB( DB_MASTER );
$isSqlite = $GLOBALS['wgDBtype'] === 'sqlite';
+ $isPostgres = $GLOBALS['wgDBtype'] === 'postgres';
$idField = $isSqlite ? 'INTEGER' : 'INT unsigned';
$primaryKey = $isSqlite ? 'PRIMARY KEY AUTOINCREMENT' :
'auto_increment PRIMARY KEY';
- $dbw->query(
- 'CREATE TABLE IF NOT EXISTS ' . $dbw->tableName(
'orm_test' ) . '(
- test_id ' . $idField . '
NOT NULL ' . $primaryKey . ',
- test_name VARCHAR(255)
NOT NULL,
- test_age TINYINT unsigned
NOT NULL,
- test_height FLOAT
NOT NULL,
- test_awesome TINYINT unsigned
NOT NULL,
- test_stuff BLOB
NOT NULL,
- test_moarstuff BLOB
NOT NULL,
- test_time varbinary(14)
NOT NULL
- );',
- __METHOD__
- );
+ if ( $isPostgres ) {
+ $dbw->query(
+ 'CREATE TABLE IF NOT EXISTS ' .
$dbw->tableName( 'orm_test' ) . "(
+ test_id serial PRIMARY KEY,
+ test_name TEXT NOT NULL DEFAULT '',
+ test_age INTEGER NOT NULL DEFAULT 0,
+ test_height REAL NOT NULL DEFAULT 0,
+ test_awesome INTEGER NOT NULL DEFAULT 0,
+ test_stuff BYTEA,
+ test_moarstuff BYTEA,
+ test_time TIMESTAMPTZ
+ );",
+ __METHOD__
+ );
+ } else {
+ $dbw->query(
+ 'CREATE TABLE IF NOT EXISTS ' .
$dbw->tableName( 'orm_test' ) . '(
+ test_id ' . $idField
. ' NOT NULL ' . $primaryKey . ',
+ test_name VARCHAR(255)
NOT NULL,
+ test_age TINYINT
unsigned NOT NULL,
+ test_height FLOAT
NOT NULL,
+ test_awesome TINYINT
unsigned NOT NULL,
+ test_stuff BLOB
NOT NULL,
+ test_moarstuff BLOB
NOT NULL,
+ test_time
varbinary(14) NOT NULL
+ );',
+ __METHOD__
+ );
+ }
}
protected function tearDown() {
@@ -91,11 +108,12 @@
}
public function constructorTestProvider() {
+ $dbw = wfGetDB( DB_MASTER );
return array(
array(
array(
'name' => 'Foobar',
- 'time' => '20120101020202',
+ 'time' =>
$dbw->timestamp('20120101020202'),
'age' => 42,
'height' => 9000.1,
'awesome' => true,
--
To view, visit https://gerrit.wikimedia.org/r/58422
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia4321727f6f1eab65c91d9876f87d51b545a72c2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brent Garber <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits