MediaWiki  REL1_24
MediaWikiMediaTestCase.php
Go to the documentation of this file.
00001 <?php
00005 abstract class MediaWikiMediaTestCase extends MediaWikiTestCase {
00006 
00008     protected $repo;
00010     protected $backend;
00012     protected $filePath;
00013 
00014 
00015     protected function setUp() {
00016         parent::setUp();
00017 
00018         $this->filePath = $this->getFilePath();
00019         $containers = array( 'data' => $this->filePath );
00020         if ( $this->createsThumbnails() ) {
00021             // We need a temp directory for the thumbnails
00022             // the container is named 'temp-thumb' because it is the
00023             // thumb directory for a FSRepo named "temp".
00024             $containers['temp-thumb'] = $this->getNewTempDirectory();
00025         }
00026 
00027         $this->backend = new FSFileBackend( array(
00028             'name' => 'localtesting',
00029             'wikiId' => wfWikiId(),
00030             'containerPaths' => $containers
00031         ) );
00032         $this->repo = new FSRepo( $this->getRepoOptions() );
00033     }
00034 
00038     protected function getRepoOptions() {
00039         return array(
00040             'name' => 'temp',
00041             'url' => 'http://localhost/thumbtest',
00042             'backend' => $this->backend
00043         );
00044     }
00045 
00052     protected function getFilePath() {
00053         return __DIR__ . '/../../data/media/';
00054     }
00055 
00064     protected function createsThumbnails() {
00065         return false;
00066     }
00067 
00076     protected function dataFile( $name, $type = null ) {
00077         if ( !$type ) {
00078             // Autodetect by file extension for the lazy.
00079             $magic = MimeMagic::singleton();
00080             $parts = explode( $name, '.' );
00081             $type = $magic->guessTypesForExtension( $parts[count( $parts ) - 1] );
00082         }
00083         return new UnregisteredLocalFile( false, $this->repo,
00084             "mwstore://localtesting/data/$name", $type );
00085     }
00086 }