Add @covers tags to media tests
[lhc/web/wiklou.git] / tests / phpunit / includes / media / MediaWikiMediaTestCase.php
index 1b8ecf2..a4e8056 100644 (file)
@@ -1,53 +1,53 @@
 <?php
 /**
- * Specificly for testing Media handlers. Sets up a FSFile backend
+ * Specificly for testing Media handlers. Sets up a FileRepo backend
  */
 abstract class MediaWikiMediaTestCase extends MediaWikiTestCase {
 
-       /** @var FSRepo */
+       /** @var FileRepo */
        protected $repo;
        /** @var FSFileBackend */
        protected $backend;
        /** @var string */
        protected $filePath;
 
-
        protected function setUp() {
                parent::setUp();
 
                $this->filePath = $this->getFilePath();
-               $containers = array( 'data' => $this->filePath );
+               $containers = [ 'data' => $this->filePath ];
                if ( $this->createsThumbnails() ) {
                        // We need a temp directory for the thumbnails
                        // the container is named 'temp-thumb' because it is the
-                       // thumb directory for a FSRepo named "temp".
+                       // thumb directory for a repo named "temp".
                        $containers['temp-thumb'] = $this->getNewTempDirectory();
                }
 
-               $this->backend = new FSFileBackend( array(
+               $this->backend = new FSFileBackend( [
                        'name' => 'localtesting',
-                       'wikiId' => wfWikiId(),
-                       'containerPaths' => $containers
-               ) );
-               $this->repo = new FSRepo( $this->getRepoOptions() );
+                       'wikiId' => wfWikiID(),
+                       'containerPaths' => $containers,
+                       'tmpDirectory' => $this->getNewTempDirectory()
+               ] );
+               $this->repo = new FileRepo( $this->getRepoOptions() );
        }
 
        /**
-        * @return Array Argument for FSRepo constructor
+        * @return array Argument for FileRepo constructor
         */
        protected function getRepoOptions() {
-               return array(
+               return [
                        'name' => 'temp',
                        'url' => 'http://localhost/thumbtest',
                        'backend' => $this->backend
-               );
+               ];
        }
 
        /**
         * The result of this method will set the file path to use,
         * as well as the protected member $filePath
         *
-        * @return String path where files are
+        * @return string Path where files are
         */
        protected function getFilePath() {
                return __DIR__ . '/../../data/media/';
@@ -59,7 +59,7 @@ abstract class MediaWikiMediaTestCase extends MediaWikiTestCase {
         *
         * Override this method if your test case creates thumbnails
         *
-        * @return boolean
+        * @return bool
         */
        protected function createsThumbnails() {
                return false;
@@ -69,14 +69,14 @@ abstract class MediaWikiMediaTestCase extends MediaWikiTestCase {
         * Utility function: Get a new file object for a file on disk but not actually in db.
         *
         * File must be in the path returned by getFilePath()
-        * @param $name String File name
-        * @param $type String MIME type [optional]
+        * @param string $name File name
+        * @param string $type MIME type [optional]
         * @return UnregisteredLocalFile
         */
        protected function dataFile( $name, $type = null ) {
                if ( !$type ) {
                        // Autodetect by file extension for the lazy.
-                       $magic = MimeMagic::singleton();
+                       $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
                        $parts = explode( $name, '.' );
                        $type = $magic->guessTypesForExtension( $parts[count( $parts ) - 1] );
                }