r110200 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110199‎ | r110200 | r110201 >
Date:01:20, 28 January 2012
Author:aaron
Status:ok
Tags:filebackend 
Comment:
* 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.
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php
@@ -695,7 +695,7 @@
696696 $this->assertEquals( true, $status->isOK(),
697697 "Creation of file at $source succeeded with OK status ($backendName)." );
698698
699 - $newContents = $this->backend->getFileContents( array( 'src' => $source ) );
 699+ $newContents = $this->backend->getFileContents( array( 'src' => $source, 'latest' => 1 ) );
700700 $this->assertNotEquals( false, $newContents,
701701 "Read of file at $source succeeded ($backendName)." );
702702
@@ -972,8 +972,8 @@
973973 // Add the files
974974 $ops = array();
975975 foreach ( $files as $file ) {
976 - $ops[] = array( 'op' => 'create', 'content' => 'xxy', 'dst' => $file );
977976 $this->prepare( array( 'dir' => dirname( $file ) ) );
 977+ $ops[] = array( 'op' => 'create', 'content' => 'xxy', 'dst' => $file );
978978 }
979979 $status = $this->backend->doOperations( $ops );
980980 $this->assertEquals( array(), $status->errors,
@@ -1055,9 +1055,6 @@
10561056 foreach ( $files as $file ) { // clean up
10571057 $this->backend->doOperation( array( 'op' => 'delete', 'src' => $file ) );
10581058 }
1059 - foreach ( $files as $file ) { // clean up
1060 - $this->recursiveClean( FileBackend::parentStoragePath( $file ) );
1061 - }
10621059
10631060 $iter = $this->backend->getFileList( array( 'dir' => "$base/unittest-cont1/not/exists" ) );
10641061 foreach ( $iter as $iter ) {} // no errors
Index: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
@@ -8,11 +8,11 @@
99 * @group Stub
1010 */
1111 class NewParserTest extends MediaWikiTestCase {
12 -
1312 static protected $articles = array(); // Array of test articles defined by the tests
1413 /* The dataProvider is run on a different instance than the test, so it must be static
1514 * When running tests from several files, all tests will see all articles.
1615 */
 16+ static protected $backendToUse;
1717
1818 public $keepUploads = false;
1919 public $runDisabled = false;
@@ -234,6 +234,7 @@
235235 * Ideally this should replace the global configuration entirely.
236236 */
237237 protected function setupGlobals( $opts = '', $config = '' ) {
 238+ global $wgFileBackends;
238239 # Find out values for some special options.
239240 $lang =
240241 self::getOptionValue( 'language', $opts, 'en' );
@@ -245,14 +246,32 @@
246247 self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 );
247248
248249 $uploadDir = $this->getUploadDir();
249 - $backend = new FSFileBackend( array(
250 - 'name' => 'local-backend',
251 - 'lockManager' => 'nullLockManager',
252 - 'containerPaths' => array(
253 - 'local-public' => "$uploadDir",
254 - 'local-thumb' => "$uploadDir/thumb",
255 - )
256 - ) );
 250+ if ( $this->getCliArg( 'use-filebackend=' ) ) {
 251+ if ( self::$backendToUse ) {
 252+ $backend = self::$backendToUse;
 253+ } else {
 254+ $name = $this->getCliArg( 'use-filebackend=' );
 255+ $useConfig = array();
 256+ foreach ( $wgFileBackends as $conf ) {
 257+ if ( $conf['name'] == $name ) {
 258+ $useConfig = $conf;
 259+ }
 260+ }
 261+ $useConfig['name'] = 'local-backend'; // swap name
 262+ $class = $conf['class'];
 263+ self::$backendToUse = new $class( $useConfig );
 264+ $backend = self::$backendToUse;
 265+ }
 266+ } else {
 267+ $backend = new FSFileBackend( array(
 268+ 'name' => 'local-backend',
 269+ 'lockManager' => 'nullLockManager',
 270+ 'containerPaths' => array(
 271+ 'local-public' => "$uploadDir",
 272+ 'local-thumb' => "$uploadDir/thumb",
 273+ )
 274+ ) );
 275+ }
257276
258277 $settings = array(
259278 'wgServer' => 'http://Britney-Spears',

Status & tagging log