$filename = 'Foo.png';
- $this->tmpPrefix = wfTempDir() . '/migratefilelayout-test-' . time() . '-' . mt_rand();
+ $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' )
->disableOriginalConstructor()
$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(
+ [ 'getMasterDB' ],
+ [ [
'name' => 'migratefilerepolayouttest',
'backend' => $backend
- ) ) );
+ ] ] );
- $repoMock->expects( $this->any() )->method( 'getMasterDB' )->will( $this->returnValue( $dbMock ) );
+ $repoMock
+ ->expects( $this->any() )
+ ->method( 'getMasterDB' )
+ ->will( $this->returnValue( $dbMock ) );
- $this->migratorMock = $this->getMock( 'MigrateFileRepoLayout', array( 'getRepo' ) );
- $this->migratorMock->expects( $this->any() )->method( 'getRepo' )->will( $this->returnValue( $repoMock ) );
+ $this->migratorMock = $this->getMock( 'MigrateFileRepoLayout', [ 'getRepo' ] );
+ $this->migratorMock
+ ->expects( $this->any() )
+ ->method( 'getRepo' )
+ ->will( $this->returnValue( $repoMock ) );
$this->tmpFilepath = TempFSFile::factory( 'migratefilelayout-test-', 'png' )->getPath();
$hashPath = $repoMock->getHashPath( $filename );
- $status = $repoMock->store( $this->tmpFilepath, 'public', $hashPath . $filename, FileRepo::OVERWRITE );
+ $status = $repoMock->store(
+ $this->tmpFilepath,
+ 'public',
+ $hashPath . $filename,
+ FileRepo::OVERWRITE
+ );
}
protected function deleteFilesRecursively( $directory ) {
}
}
- rmdir( $directory );
+ rmdir( $directory );
}
protected function tearDown() {
}
public function testMigration() {
- $this->migratorMock->loadParamsAndArgs( null, array( 'oldlayout' => 'name', 'newlayout' => 'sha1' ) );
+ $this->migratorMock->loadParamsAndArgs(
+ null,
+ [ 'oldlayout' => 'name', 'newlayout' => 'sha1' ]
+ );
ob_start();
. '/'
. $sha1;
- $this->assertEquals( file_get_contents( $expectedOriginalFilepath ), $this->text, 'New sha1 file should be exist and have the right contents' );
+ $this->assertEquals(
+ file_get_contents( $expectedOriginalFilepath ),
+ $this->text,
+ 'New sha1 file should be exist and have the right contents'
+ );
$expectedPublicFilepath = $this->tmpPrefix . '-public/f/f8/Foo.png';
- $this->assertEquals( file_get_contents( $expectedPublicFilepath ), $this->text, 'Existing name file should still and have the right contents' );
+ $this->assertEquals(
+ file_get_contents( $expectedPublicFilepath ),
+ $this->text,
+ 'Existing name file should still and have the right contents'
+ );
}
}