tests: mock parser tests file access
[lhc/web/wiklou.git] / tests / phpunit / includes / parser / NewParserTest.php
index d66fac7..f41c71c 100644 (file)
@@ -110,6 +110,14 @@ class NewParserTest extends MediaWikiTestCase {
                        $tmpGlobals['wgStyleDirectory'] = "$IP/skins";
                }
 
+               # Replace all media handlers with a mock. We do not need to generate
+               # actual thumbnails to do parser testing, we only care about receiving
+               # a ThumbnailImage properly initialized.
+               global $wgMediaHandlers;
+               foreach( $wgMediaHandlers as $type => $handler ) {
+                       $tmpGlobals['wgMediaHandlers'][$type] = 'MockBitmapHandler';
+               }
+
                $tmpHooks = $wgHooks;
                $tmpHooks['ParserTestParser'][] = 'ParserTestParserHook::setup';
                $tmpHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
@@ -301,7 +309,10 @@ class NewParserTest extends MediaWikiTestCase {
                                $backend = self::$backendToUse;
                        }
                } else {
-                       $backend = new FSFileBackend( array(
+                       # Replace with a mock. We do not care about generating real
+                       # files on the filesystem, just need to expose the file
+                       # informations.
+                       $backend = new MockFileBackend( array(
                                'name' => 'local-backend',
                                'lockManager' => 'nullLockManager',
                                'containerPaths' => array(
@@ -456,6 +467,12 @@ class NewParserTest extends MediaWikiTestCase {
                        return;
                }
 
+               $backend = RepoGroup::singleton()->getLocalRepo()->getBackend();
+               if( $backend instanceof MockFileBackend ) {
+                       # In memory backend, so dont bother cleaning them up.
+                       return;
+               }
+
                $base = $this->getBaseDir();
                // delete the files first, then the dirs.
                self::deleteFiles(