Merge "Add .gitignore to the /skins directory"
[lhc/web/wiklou.git] / tests / phpunit / includes / db / TestORMRowTest.php
index 263553a..c9459c9 100644 (file)
@@ -40,6 +40,9 @@
  */
 require_once __DIR__ . "/ORMRowTest.php";
 
+/**
+ * @covers TestORMRow
+ */
 class TestORMRowTest extends ORMRowTest {
 
        /**
@@ -64,23 +67,40 @@ class TestORMRowTest extends ORMRowTest {
                $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 +111,12 @@ class TestORMRowTest extends ORMRowTest {
        }
 
        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,
@@ -122,10 +143,10 @@ class TestORMRowTest extends ORMRowTest {
                        'blob' => new stdClass()
                );
        }
-
 }
 
-class TestORMRow extends ORMRow {}
+class TestORMRow extends ORMRow {
+}
 
 class TestORMTable extends ORMTable {
 
@@ -194,6 +215,4 @@ class TestORMTable extends ORMTable {
        protected function getFieldPrefix() {
                return 'test_';
        }
-
-
 }