Merge "Produce RDF dump of all categories and subcategories in a wiki."
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiTestCase.php
index 31cfa70..ed1f1ae 100644 (file)
@@ -300,7 +300,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                        'ConfigFactory',
                        self::makeTestConfigFactoryInstantiator(
                                $oldConfigFactory,
-                               [ 'main' =>  $bootstrapConfig ]
+                               [ 'main' => $bootstrapConfig ]
                        )
                );
                $newServices->resetServiceForTesting( 'DBLoadBalancerFactory' );
@@ -1087,10 +1087,15 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                        $page->doEditContent(
                                new WikitextContent( 'UTContent' ),
                                'UTPageSummary',
-                               EDIT_NEW,
+                               EDIT_NEW | EDIT_SUPPRESS_RC,
                                false,
                                $user
                        );
+                       // an edit always attempt to purge backlink links such as history
+                       // pages. That is unneccessary.
+                       JobQueueGroup::singleton()->get( 'htmlCacheUpdate' )->delete();
+                       // WikiPages::doEditUpdates randomly adds RC purges
+                       JobQueueGroup::singleton()->get( 'recentChangesUpdate' )->delete();
 
                        // doEditContent() probably started the session via
                        // User::loadFromSession(). Close it now.
@@ -1249,7 +1254,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
         *
         * @return Database[] Array of Database master connections
         */
-
        protected static function getExternalStoreDatabaseConnections() {
                global $wgDefaultExternalStore;
 
@@ -1485,7 +1489,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                                ' method should return true. Use @group Database or $this->tablesUsed.' );
                }
 
-               $db = wfGetDB( DB_SLAVE );
+               $db = wfGetDB( DB_REPLICA );
 
                $res = $db->select( $table, $fields, $condition, wfGetCaller(), [ 'ORDER BY' => $fields ] );
                $this->assertNotEmpty( $res, "query failed: " . $db->lastError() );
@@ -1841,4 +1845,29 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                $this->mergeMwGlobalArrayValue( 'wgHooks', [ $hookName => [ $handler ] ] );
        }
 
+       /**
+        * Check whether file contains given data.
+        * @param string $fileName
+        * @param string $actualData
+        * @param bool $createIfMissing If true, and file does not exist, create it with given data
+        *                              and skip the test.
+        * @param string $msg
+        * @since 1.30
+        */
+       protected function assertFileContains(
+               $fileName,
+               $actualData,
+               $createIfMissing = true,
+               $msg = ''
+       ) {
+               if ( $createIfMissing ) {
+                       if ( !file_exists( $fileName ) ) {
+                               file_put_contents( $fileName, $actualData );
+                               $this->markTestSkipped( 'Data file $fileName does not exist' );
+                       }
+               } else {
+                       self::assertFileExists( $fileName );
+               }
+               self::assertEquals( file_get_contents( $fileName ), $actualData, $msg );
+       }
 }