<?php
/**
- * @group Filerepo
+ * @group FileRepo
*/
class StoreBatchTest extends MediaWikiTestCase {
public function setUp() {
+ global $wgFileBackends;
parent::setUp();
# Forge a FSRepo object to not have to rely on local wiki settings
- $tmpDir = wfTempDir() . '/' . time() . '-' . mt_rand();
- $this->repo = new FSRepo( array(
- 'name' => 'test',
- 'backend' => new FSFileBackend( array(
- 'name' => 'local-backend',
+ $tmpPrefix = wfTempDir() . '/storebatch-test-' . time() . '-' . mt_rand();
+ if ( $this->getCliArg( 'use-filebackend=' ) ) {
+ $name = $this->getCliArg( 'use-filebackend=' );
+ $useConfig = array();
+ foreach ( $wgFileBackends as $conf ) {
+ if ( $conf['name'] == $name ) {
+ $useConfig = $conf;
+ }
+ }
+ $useConfig['name'] = 'local-testing'; // swap name
+ $class = $useConfig['class'];
+ $backend = new $class( $useConfig );
+ } else {
+ $backend = new FSFileBackend( array(
+ 'name' => 'local-testing',
'lockManager' => 'nullLockManager',
'containerPaths' => array(
- 'test-public' => "$tmpDir/public",
- 'test-thumb' => "$tmpDir/thumb",
- 'test-temp' => "$tmpDir/temp",
- 'test-deleted' => "$tmpDir/deleted",
+ 'unittests-public' => "{$tmpPrefix}-public",
+ 'unittests-thumb' => "{$tmpPrefix}-thumb",
+ 'unittests-temp' => "{$tmpPrefix}-temp",
+ 'unittests-deleted' => "{$tmpPrefix}-deleted",
)
- ) )
+ ) );
+ }
+ $this->repo = new FileRepo( array(
+ 'name' => 'unittests',
+ 'backend' => $backend
) );
$this->date = gmdate( "YmdHis" );
$this->createdFiles = array();
-
- $this->users = array(
- 'sysop' => new ApiTestUser(
- 'Uploadstashtestsysop',
- 'Upload Stash Test Sysop',
- 'upload_stash_test_sysop@example.com',
- array( 'sysop' )
- ),
- 'uploader' => new ApiTestUser(
- 'Uploadstashtestuser',
- 'Upload Stash Test User',
- 'upload_stash_test_user@example.com',
- array()
- )
- );
}
/**
}
public function tearDown() {
- $this->repo->cleanupBatch( $this->createdFiles );
+ $this->repo->cleanupBatch( $this->createdFiles ); // delete files
+ foreach ( $this->createdFiles as $tmp ) { // delete dirs
+ $tmp = $this->repo->resolveVirtualUrl( $tmp );
+ while ( $tmp = FileBackend::parentStoragePath( $tmp ) ) {
+ $this->repo->getBackend()->clean( array( 'dir' => $tmp ) );
+ }
+ }
parent::tearDown();
}
}