Merge "phpunit: Avoid use of deprecated getMock for PHPUnit 5 compat"
[lhc/web/wiklou.git] / tests / phpunit / includes / filerepo / MigrateFileRepoLayoutTest.php
index ee0cf2d..800c2fc 100644 (file)
@@ -13,19 +13,19 @@ class MigrateFileRepoLayoutTest extends MediaWikiTestCase {
 
                $this->tmpPrefix = $this->getNewTempDirectory();
 
-               $backend = new FSFileBackend( array(
+               $backend = new FSFileBackend( [
                        'name' => 'local-migratefilerepolayouttest',
                        'wikiId' => wfWikiID(),
-                       'containerPaths' => array(
+                       'containerPaths' => [
                                'migratefilerepolayouttest-original' => "{$this->tmpPrefix}-original",
                                'migratefilerepolayouttest-public' => "{$this->tmpPrefix}-public",
                                'migratefilerepolayouttest-thumb' => "{$this->tmpPrefix}-thumb",
                                'migratefilerepolayouttest-temp' => "{$this->tmpPrefix}-temp",
                                'migratefilerepolayouttest-deleted' => "{$this->tmpPrefix}-deleted",
-                       )
-               ) );
+                       ]
+               ] );
 
-               $dbMock = $this->getMockBuilder( 'DatabaseMysql' )
+               $dbMock = $this->getMockBuilder( 'DatabaseMysqli' )
                        ->disableOriginalConstructor()
                        ->getMock();
 
@@ -36,30 +36,33 @@ class MigrateFileRepoLayoutTest extends MediaWikiTestCase {
                $dbMock->expects( $this->any() )
                        ->method( 'select' )
                        ->will( $this->onConsecutiveCalls(
-                               new FakeResultWrapper( array( $imageRow ) ), // image
-                               new FakeResultWrapper( array() ), // image
-                               new FakeResultWrapper( array() ) // filearchive
+                               new FakeResultWrapper( [ $imageRow ] ), // image
+                               new FakeResultWrapper( [] ), // image
+                               new FakeResultWrapper( [] ) // filearchive
                        ) );
 
-               $repoMock = $this->getMock( 'LocalRepo',
-                       array( 'getMasterDB' ),
-                       array( array(
-                               'name' => 'migratefilerepolayouttest',
-                               'backend' => $backend
-                       ) ) );
+               $repoMock = $this->getMockBuilder( 'LocalRepo' )
+                       ->setMethods( [ 'getMasterDB' ] )
+                       ->setConstructorArgs( [ [
+                                       'name' => 'migratefilerepolayouttest',
+                                       'backend' => $backend
+                               ] ] )
+                       ->getMock();
 
                $repoMock
                        ->expects( $this->any() )
                        ->method( 'getMasterDB' )
                        ->will( $this->returnValue( $dbMock ) );
 
-               $this->migratorMock = $this->getMock( 'MigrateFileRepoLayout', array( 'getRepo' ) );
+               $this->migratorMock = $this->getMockBuilder( 'MigrateFileRepoLayout' )
+                       ->setMethods( [ 'getRepo' ] )->getMock();
                $this->migratorMock
                        ->expects( $this->any() )
                        ->method( 'getRepo' )
                        ->will( $this->returnValue( $repoMock ) );
 
-               $this->tmpFilepath = TempFSFile::factory( 'migratefilelayout-test-', 'png' )->getPath();
+               $this->tmpFilepath = TempFSFile::factory(
+                       'migratefilelayout-test-', 'png', wfTempDir() )->getPath();
 
                file_put_contents( $this->tmpFilepath, $this->text );
 
@@ -98,7 +101,7 @@ class MigrateFileRepoLayoutTest extends MediaWikiTestCase {
        public function testMigration() {
                $this->migratorMock->loadParamsAndArgs(
                        null,
-                       array( 'oldlayout' => 'name', 'newlayout' => 'sha1' )
+                       [ 'oldlayout' => 'name', 'newlayout' => 'sha1' ]
                );
 
                ob_start();