Merge "Warn if stateful ParserOutput transforms are used"
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiTestCase.php
index 10f5d41..fe8c917 100644 (file)
@@ -260,7 +260,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                 * which we can't allow, as that would open a new connection for mysql.
                 * Replace with a HashBag. They would not be going to persist anyway.
                 */
-               $hashCache = [ 'class' => 'HashBagOStuff', 'reportDupes' => false ];
+               $hashCache = [ 'class' => HashBagOStuff::class, 'reportDupes' => false ];
                $objectCaches = [
                                CACHE_DB => $hashCache,
                                CACHE_ACCEL => $hashCache,
@@ -273,7 +273,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
 
                $defaultOverrides->set( 'ObjectCaches', $objectCaches );
                $defaultOverrides->set( 'MainCacheType', CACHE_NONE );
-               $defaultOverrides->set( 'JobTypeConf', [ 'default' => [ 'class' => 'JobQueueMemory' ] ] );
+               $defaultOverrides->set( 'JobTypeConf', [ 'default' => [ 'class' => JobQueueMemory::class ] ] );
 
                // Use a fast hash algorithm to hash passwords.
                $defaultOverrides->set( 'PasswordDefault', 'A' );
@@ -1393,9 +1393,8 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                $this->ensureMockDatabaseConnection( $db );
 
                foreach ( $tables as $tbl ) {
-                       $tmp = self::$useTemporaryTables ? ' TEMPORARY ' : '';
                        $tbl = $db->tableName( $tbl );
-                       $db->query( "DROP $tmp TABLE IF EXISTS $tbl", __METHOD__ );
+                       $db->query( "DROP TABLE IF EXISTS $tbl", __METHOD__ );
 
                        if ( $tbl === 'page' ) {
                                // Forget about the pages since they don't
@@ -1614,13 +1613,17 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
         * @param string|array $fields The columns to include in the result (and to sort by)
         * @param string|array $condition "where" condition(s)
         * @param array $expectedRows An array of arrays giving the expected rows.
+        * @param array $options Options for the query
+        * @param array $join_conds Join conditions for the query
         *
         * @throws MWException If this test cases's needsDB() method doesn't return true.
         *         Test cases can use "@group Database" to enable database test support,
         *         or list the tables under testing in $this->tablesUsed, or override the
         *         needsDB() method.
         */
-       protected function assertSelect( $table, $fields, $condition, array $expectedRows ) {
+       protected function assertSelect(
+               $table, $fields, $condition, array $expectedRows, array $options = [], array $join_conds = []
+       ) {
                if ( !$this->needsDB() ) {
                        throw new MWException( 'When testing database state, the test cases\'s needDB()' .
                                ' method should return true. Use @group Database or $this->tablesUsed.' );
@@ -1628,7 +1631,14 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
 
                $db = wfGetDB( DB_REPLICA );
 
-               $res = $db->select( $table, $fields, $condition, wfGetCaller(), [ 'ORDER BY' => $fields ] );
+               $res = $db->select(
+                       $table,
+                       $fields,
+                       $condition,
+                       wfGetCaller(),
+                       $options + [ 'ORDER BY' => $fields ],
+                       $join_conds
+               );
                $this->assertNotEmpty( $res, "query failed: " . $db->lastError() );
 
                $i = 0;