$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)." );
// 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,
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
* @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;
* 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' );
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',