3 * Specificly for testing Media handlers. Sets up a FSFile backend
5 abstract class MediaWikiMediaTestCase
extends MediaWikiTestCase
{
9 /** @var FSFileBackend */
15 protected function setUp() {
18 $this->filePath
= $this->getFilePath();
19 $containers = array( 'data' => $this->filePath
);
20 if ( $this->createsThumbnails() ) {
21 // We need a temp directory for the thumbnails
22 // the container is named 'temp-thumb' because it is the
23 // thumb directory for a FSRepo named "temp".
24 $containers['temp-thumb'] = $this->getNewTempDirectory();
27 $this->backend
= new FSFileBackend( array(
28 'name' => 'localtesting',
29 'wikiId' => wfWikiId(),
30 'containerPaths' => $containers
32 $this->repo
= new FSRepo( array(
34 'url' => 'http://localhost/thumbtest',
35 'backend' => $this->backend
40 * The result of this method will set the file path to use,
41 * as well as the protected member $filePath
43 * @return String path where files are
45 protected function getFilePath() {
46 return __DIR__
. '/../../data/media/';
50 * Will the test create thumbnails (and thus do we need to set aside
51 * a temporary directory for them?)
53 * Override this method if your test case creates thumbnails
57 protected function createsThumbnails() {
62 * Utility function: Get a new file object for a file on disk but not actually in db.
64 * File must be in the path returned by getFilePath()
65 * @param $name String File name
66 * @param $type String MIME type
67 * @return UnregisteredLocalFile
69 protected function dataFile( $name, $type ) {
70 return new UnregisteredLocalFile( false, $this->repo
,
71 "mwstore://localtesting/data/$name", $type );