Merge "Use IResultWrapper in code comments instead of ResultWrapper"
[lhc/web/wiklou.git] / tests / phpunit / includes / db / DatabasePostgresTest.php
index 5c2aa2b..e0b8111 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Wikimedia\Rdbms\Database;
 use Wikimedia\Rdbms\IDatabase;
 use Wikimedia\Rdbms\DatabasePostgres;
 use Wikimedia\ScopedCallback;
@@ -11,15 +12,17 @@ use Wikimedia\TestingAccessWrapper;
 class DatabasePostgresTest extends MediaWikiTestCase {
 
        private function doTestInsertIgnore() {
-               $reset = new ScopedCallback( function () {
+               $fname = __METHOD__;
+               $reset = new ScopedCallback( function () use ( $fname ) {
                        if ( $this->db->explicitTrxActive() ) {
-                               $this->db->rollback( __METHOD__ );
+                               $this->db->rollback( $fname );
                        }
-                       $this->db->query( 'DROP TABLE IF EXISTS ' . $this->db->tableName( 'foo' ) );
+                       $this->db->query( 'DROP TABLE IF EXISTS ' . $this->db->tableName( 'foo' ), $fname );
                } );
 
                $this->db->query(
-                       "CREATE TEMPORARY TABLE {$this->db->tableName( 'foo' )} (i INTEGER NOT NULL PRIMARY KEY)"
+                       "CREATE TEMPORARY TABLE {$this->db->tableName( 'foo' )} (i INTEGER NOT NULL PRIMARY KEY)",
+                       __METHOD__
                );
                $this->db->insert( 'foo', [ [ 'i' => 1 ], [ 'i' => 2 ] ], __METHOD__ );
 
@@ -92,19 +95,22 @@ class DatabasePostgresTest extends MediaWikiTestCase {
        }
 
        private function doTestInsertSelectIgnore() {
-               $reset = new ScopedCallback( function () {
+               $fname = __METHOD__;
+               $reset = new ScopedCallback( function () use ( $fname ) {
                        if ( $this->db->explicitTrxActive() ) {
-                               $this->db->rollback( __METHOD__ );
+                               $this->db->rollback( $fname );
                        }
-                       $this->db->query( 'DROP TABLE IF EXISTS ' . $this->db->tableName( 'foo' ) );
-                       $this->db->query( 'DROP TABLE IF EXISTS ' . $this->db->tableName( 'bar' ) );
+                       $this->db->query( 'DROP TABLE IF EXISTS ' . $this->db->tableName( 'foo' ), $fname );
+                       $this->db->query( 'DROP TABLE IF EXISTS ' . $this->db->tableName( 'bar' ), $fname );
                } );
 
                $this->db->query(
-                       "CREATE TEMPORARY TABLE {$this->db->tableName( 'foo' )} (i INTEGER)"
+                       "CREATE TEMPORARY TABLE {$this->db->tableName( 'foo' )} (i INTEGER)",
+                       __METHOD__
                );
                $this->db->query(
-                       "CREATE TEMPORARY TABLE {$this->db->tableName( 'bar' )} (i INTEGER NOT NULL PRIMARY KEY)"
+                       "CREATE TEMPORARY TABLE {$this->db->tableName( 'bar' )} (i INTEGER NOT NULL PRIMARY KEY)",
+                       __METHOD__
                );
                $this->db->insert( 'bar', [ [ 'i' => 1 ], [ 'i' => 2 ] ], __METHOD__ );
 
@@ -174,4 +180,10 @@ class DatabasePostgresTest extends MediaWikiTestCase {
                $this->doTestInsertSelectIgnore();
        }
 
+       /**
+        * @covers \Wikimedia\Rdbms\DatabasePostgres::getAttributes
+        */
+       public function testAttributes() {
+               $this->assertTrue( DatabasePostgres::getAttributes()[Database::ATTR_SCHEMAS_AS_TABLE_GROUPS] );
+       }
 }