* In NewParserTest, made it possible to use the --use-filebackend param to run the...
authorAaron Schulz <aaron@users.mediawiki.org>
Sat, 28 Jan 2012 01:20:42 +0000 (01:20 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sat, 28 Jan 2012 01:20:42 +0000 (01:20 +0000)
* In FileBackendTest, killed useless recursiveClean() call.

tests/phpunit/includes/filerepo/FileBackendTest.php
tests/phpunit/includes/parser/NewParserTest.php

index b1d9563..d5823d8 100644 (file)
@@ -695,7 +695,7 @@ class FileBackendTest extends MediaWikiTestCase {
                $this->assertEquals( true, $status->isOK(),
                        "Creation of file at $source succeeded with OK status ($backendName)." );
 
-               $newContents = $this->backend->getFileContents( array( 'src' => $source ) );
+               $newContents = $this->backend->getFileContents( array( 'src' => $source, 'latest' => 1 ) );
                $this->assertNotEquals( false, $newContents,
                        "Read of file at $source succeeded ($backendName)." );
 
@@ -972,8 +972,8 @@ class FileBackendTest extends MediaWikiTestCase {
                // Add the files
                $ops = array();
                foreach ( $files as $file ) {
-                       $ops[] = array( 'op' => 'create', 'content' => 'xxy', 'dst' => $file );
                        $this->prepare( array( 'dir' => dirname( $file ) ) );
+                       $ops[] = array( 'op' => 'create', 'content' => 'xxy', 'dst' => $file );
                }
                $status = $this->backend->doOperations( $ops );
                $this->assertEquals( array(), $status->errors,
@@ -1055,9 +1055,6 @@ class FileBackendTest extends MediaWikiTestCase {
                foreach ( $files as $file ) { // clean up
                        $this->backend->doOperation( array( 'op' => 'delete', 'src' => $file ) );
                }
-               foreach ( $files as $file ) { // clean up
-                       $this->recursiveClean( FileBackend::parentStoragePath( $file ) );
-               }
 
                $iter = $this->backend->getFileList( array( 'dir' => "$base/unittest-cont1/not/exists" ) );
                foreach ( $iter as $iter ) {} // no errors
index cfbaab3..d1221ca 100644 (file)
@@ -8,11 +8,11 @@
  * @group Stub
  */
 class NewParserTest extends MediaWikiTestCase {
-
        static protected $articles = array();   // Array of test articles defined by the tests
        /* The dataProvider is run on a different instance than the test, so it must be static
         * When running tests from several files, all tests will see all articles.
         */
+       static protected $backendToUse;
 
        public $keepUploads = false;
        public $runDisabled = false;
@@ -234,6 +234,7 @@ class NewParserTest extends MediaWikiTestCase {
         * Ideally this should replace the global configuration entirely.
         */
        protected function setupGlobals( $opts = '', $config = '' ) {
+               global $wgFileBackends;
                # Find out values for some special options.
                $lang =
                        self::getOptionValue( 'language', $opts, 'en' );
@@ -245,14 +246,32 @@ class NewParserTest extends MediaWikiTestCase {
                        self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 );
 
                $uploadDir = $this->getUploadDir();
-               $backend = new FSFileBackend( array(
-                       'name'        => 'local-backend',
-                       'lockManager' => 'nullLockManager',
-                       'containerPaths' => array(
-                               'local-public' => "$uploadDir",
-                               'local-thumb'  => "$uploadDir/thumb",
-                       )
-               ) );
+               if ( $this->getCliArg( 'use-filebackend=' ) ) {
+                       if ( self::$backendToUse ) {
+                               $backend = self::$backendToUse;
+                       } else {
+                               $name = $this->getCliArg( 'use-filebackend=' );
+                               $useConfig = array();
+                               foreach ( $wgFileBackends as $conf ) {
+                                       if ( $conf['name'] == $name ) {
+                                               $useConfig = $conf;
+                                       }
+                               }
+                               $useConfig['name'] = 'local-backend'; // swap name
+                               $class = $conf['class'];
+                               self::$backendToUse = new $class( $useConfig );
+                               $backend = self::$backendToUse;
+                       }
+               } else {
+                       $backend = new FSFileBackend( array(
+                               'name'        => 'local-backend',
+                               'lockManager' => 'nullLockManager',
+                               'containerPaths' => array(
+                                       'local-public' => "$uploadDir",
+                                       'local-thumb'  => "$uploadDir/thumb",
+                               )
+                       ) );
+               }
 
                $settings = array(
                        'wgServer' => 'http://Britney-Spears',