Merge "phpunit: Avoid use of deprecated getMock for PHPUnit 5 compat"
[lhc/web/wiklou.git] / tests / phpunit / maintenance / backupTextPassTest.php
index 893e4f9..d460401 100644 (file)
@@ -32,9 +32,9 @@ class TextPassDumperDatabaseTest extends DumpTestCase {
                $this->tablesUsed[] = 'revision';
                $this->tablesUsed[] = 'text';
 
-               $this->mergeMwGlobalArrayValue( 'wgContentHandlers', array(
+               $this->mergeMwGlobalArrayValue( 'wgContentHandlers', [
                        "BackupTextPassTestModel" => "BackupTextPassTestModelHandler"
-               ) );
+               ] );
 
                $ns = $this->getDefaultWikitextNS();
 
@@ -102,8 +102,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase {
                // class), we have to assert, that the page id are consecutively
                // increasing
                $this->assertEquals(
-                       array( $this->pageId2, $this->pageId3, $this->pageId4 ),
-                       array( $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ),
+                       [ $this->pageId2, $this->pageId3, $this->pageId4 ],
+                       [ $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ],
                        "Page ids increasing without holes" );
        }
 
@@ -111,10 +111,10 @@ class TextPassDumperDatabaseTest extends DumpTestCase {
                // Setting up the dump
                $nameStub = $this->setUpStub();
                $nameFull = $this->getNewTempFile();
-               $dumper = new TextPassDumper( array( "--stub=file:" . $nameStub,
-                       "--output=file:" . $nameFull ) );
+               $dumper = new TextPassDumper( [ "--stub=file:" . $nameStub,
+                       "--output=file:" . $nameFull ] );
                $dumper->reporting = false;
-               $dumper->setDb( $this->db );
+               $dumper->setDB( $this->db );
 
                // Performing the dump
                $dumper->dump( WikiExporter::FULL, WikiExporter::TEXT );
@@ -163,13 +163,16 @@ class TextPassDumperDatabaseTest extends DumpTestCase {
 
        function testPrefetchPlain() {
                // The mapping between ids and text, for the hits of the prefetch mock
-               $prefetchMap = array(
-                       array( $this->pageId1, $this->revId1_1, "Prefetch_________1Text1" ),
-                       array( $this->pageId2, $this->revId2_3, "Prefetch_________2Text3" )
-               );
+               $prefetchMap = [
+                       [ $this->pageId1, $this->revId1_1, "Prefetch_________1Text1" ],
+                       [ $this->pageId2, $this->revId2_3, "Prefetch_________2Text3" ]
+               ];
 
                // The mock itself
-               $prefetchMock = $this->getMock( 'BaseDump', array( 'prefetch' ), array(), '', false );
+               $prefetchMock = $this->getMockBuilder( 'BaseDump' )
+                       ->setMethods( [ 'prefetch' ] )
+                       ->disableOriginalConstructor()
+                       ->getMock();
                $prefetchMock->expects( $this->exactly( 6 ) )
                        ->method( 'prefetch' )
                        ->will( $this->returnValueMap( $prefetchMap ) );
@@ -178,12 +181,12 @@ class TextPassDumperDatabaseTest extends DumpTestCase {
                $nameStub = $this->setUpStub();
                $nameFull = $this->getNewTempFile();
 
-               $dumper = new TextPassDumper( array( "--stub=file:" . $nameStub,
-                       "--output=file:" . $nameFull ) );
+               $dumper = new TextPassDumper( [ "--stub=file:" . $nameStub,
+                       "--output=file:" . $nameFull ] );
 
                $dumper->prefetch = $prefetchMock;
                $dumper->reporting = false;
-               $dumper->setDb( $this->db );
+               $dumper->setDB( $this->db );
 
                // Performing the dump
                $dumper->dump( WikiExporter::FULL, WikiExporter::TEXT );
@@ -269,12 +272,12 @@ class TextPassDumperDatabaseTest extends DumpTestCase {
                                "Creating temporary output directory " );
                        $this->setUpStub( $nameStub, $iterations );
                        $dumper = new TextPassDumper();
-                       $dumper->loadWithArgv( array( "--stub=file:" . $nameStub,
+                       $dumper->loadWithArgv( [ "--stub=file:" . $nameStub,
                                "--output=" . $checkpointFormat . ":" . $nameOutputDir . "/full",
                                "--maxtime=1" /*This is in minutes. Fixup is below*/,
                                "--buffersize=32768", // The default of 32 iterations fill up 32KB about twice
-                               "--checkpointfile=checkpoint-%s-%s.xml.gz" ) );
-                       $dumper->setDb( $this->db );
+                               "--checkpointfile=checkpoint-%s-%s.xml.gz" ] );
+                       $dumper->setDB( $this->db );
                        $dumper->maxTimeAllowed = $checkpointAfter; // Patching maxTime from 1 minute
                        $dumper->stderr = $stderr;
 
@@ -643,7 +646,7 @@ class TextPassDumperDatabaselessTest extends MediaWikiLangTestCase {
         */
        function testBufferSizeSetting( $expected, $size, $msg ) {
                $dumper = new TextPassDumperAccessor();
-               $dumper->loadWithArgv( array( "--buffersize=" . $size ) );
+               $dumper->loadWithArgv( [ "--buffersize=" . $size ] );
                $dumper->execute();
                $this->assertEquals( $expected, $dumper->getBufferSize(), $msg );
        }
@@ -655,11 +658,11 @@ class TextPassDumperDatabaselessTest extends MediaWikiLangTestCase {
         */
        function bufferSizeProvider() {
                // expected, bufferSize to initialize with, message
-               return array(
-                       array( 512 * 1024, 512 * 1024, "Setting 512KB is not effective" ),
-                       array( 8192, 8192, "Setting 8KB is not effective" ),
-                       array( 4096, 2048, "Could set buffer size below lower bound" )
-               );
+               return [
+                       [ 512 * 1024, 512 * 1024, "Setting 512KB is not effective" ],
+                       [ 8192, 8192, "Setting 8KB is not effective" ],
+                       [ 4096, 2048, "Could set buffer size below lower bound" ]
+               ];
        }
 }