Refactored UploadStash and related classes to use the database for file metadata...
[lhc/web/wiklou.git] / tests / phpunit / includes / upload / UploadStashTest.php
1 <?php
2
3 class UploadStashTest extends MediaWikiTestCase {
4 /**
5 * @var Array of UploadStashTestUser
6 */
7 public static $users;
8
9 public function setUp() {
10 parent::setUp();
11
12 // Setup a file for bug 29408
13 $this->bug29408File = dirname( __FILE__ ) . '/bug29408';
14 file_put_contents( $this->bug29408File, "\x00" );
15
16 self::$users = array(
17 'sysop' => new ApiTestUser(
18 'Uploadstashtestsysop',
19 'Upload Stash Test Sysop',
20 'upload_stash_test_sysop@sample.com',
21 array( 'sysop' )
22 ),
23 'uploader' => new ApiTestUser(
24 'Uploadstashtestuser',
25 'Upload Stash Test User',
26 'upload_stash_test_user@sample.com',
27 array()
28 )
29 );
30 }
31
32 public function testBug29408() {
33 global $wgUser;
34 $wgUser = self::$users['uploader']->user;
35
36 $repo = RepoGroup::singleton()->getLocalRepo();
37 $stash = new UploadStash( $repo );
38
39 // Throws exception caught by PHPUnit on failure
40 $file = $stash->stashFile( $this->bug29408File );
41 // We'll never reach this point if we hit bug 29408
42 $this->assertTrue( true, 'Unrecognized file without extension' );
43
44 $stash->removeFile( $file->getFileKey() );
45 }
46
47 public function tearDown() {
48 parent::tearDown();
49
50 unlink( $this->bug29408File . "." );
51
52 }
53 }