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