From: Aaron Schulz Date: Sat, 28 Jan 2012 01:20:42 +0000 (+0000) Subject: * In NewParserTest, made it possible to use the --use-filebackend param to run the... X-Git-Tag: 1.31.0-rc.0~25040 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=638b58c27233f883817125fe6ac18d8708d8795b;p=lhc%2Fweb%2Fwiklou.git * In NewParserTest, made it possible to use the --use-filebackend param to run the tests on a given registered backend. * In FileBackendTest, killed useless recursiveClean() call. --- diff --git a/tests/phpunit/includes/filerepo/FileBackendTest.php b/tests/phpunit/includes/filerepo/FileBackendTest.php index b1d9563e77..d5823d877b 100644 --- a/tests/phpunit/includes/filerepo/FileBackendTest.php +++ b/tests/phpunit/includes/filerepo/FileBackendTest.php @@ -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 diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index cfbaab33a1..d1221ca807 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -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',