MediaWiki  1.23.14
UploadStashTest.php
Go to the documentation of this file.
1 <?php
2 
12  public static $users;
13 
17  private $bug29408File;
18 
19  protected function setUp() {
20  parent::setUp();
21 
22  // Setup a file for bug 29408
23  $this->bug29408File = __DIR__ . '/bug29408';
24  file_put_contents( $this->bug29408File, "\x00" );
25 
26  self::$users = array(
27  'sysop' => new TestUser(
28  'Uploadstashtestsysop',
29  'Upload Stash Test Sysop',
30  'upload_stash_test_sysop@example.com',
31  array( 'sysop' )
32  ),
33  'uploader' => new TestUser(
34  'Uploadstashtestuser',
35  'Upload Stash Test User',
36  'upload_stash_test_user@example.com',
37  array()
38  )
39  );
40  }
41 
42  protected function tearDown() {
43  if ( file_exists( $this->bug29408File . "." ) ) {
44  unlink( $this->bug29408File . "." );
45  }
46 
47  if ( file_exists( $this->bug29408File ) ) {
48  unlink( $this->bug29408File );
49  }
50 
51  parent::tearDown();
52  }
53 
57  public function testBug29408() {
58  $this->setMwGlobals( 'wgUser', self::$users['uploader']->user );
59 
60  $repo = RepoGroup::singleton()->getLocalRepo();
61  $stash = new UploadStash( $repo );
62 
63  // Throws exception caught by PHPUnit on failure
64  $file = $stash->stashFile( $this->bug29408File );
65  // We'll never reach this point if we hit bug 29408
66  $this->assertTrue( true, 'Unrecognized file without extension' );
67 
68  $stash->removeFile( $file->getFileKey() );
69  }
70 
71  public function provideInvalidRequests() {
72  return array(
73  'Check failure on bad wpFileKey' =>
74  array( new FauxRequest( array( 'wpFileKey' => 'foo' ) ) ),
75  'Check failure on bad wpSessionKey' =>
76  array( new FauxRequest( array( 'wpSessionKey' => 'foo' ) ) ),
77  );
78  }
79 
84  $this->assertFalse( UploadFromStash::isValidRequest( $request ) );
85  }
86 
87  public function provideValidRequests() {
88  return array(
89  'Check good wpFileKey' =>
90  array( new FauxRequest( array( 'wpFileKey' => 'testkey-test.test' ) ) ),
91  'Check good wpSessionKey' =>
92  array( new FauxRequest( array( 'wpFileKey' => 'testkey-test.test' ) ) ),
93  'Check key precedence' =>
94  array( new FauxRequest( array(
95  'wpFileKey' => 'testkey-test.test',
96  'wpSessionKey' => 'foo'
97  ) ) ),
98  );
99  }
103  public function testValidRequestWithValidRequests( $request ) {
104  $this->assertTrue( UploadFromStash::isValidRequest( $request ) );
105  }
106 
107 }
UploadStashTest\testBug29408
testBug29408()
Definition: UploadStashTest.php:56
FauxRequest
WebRequest clone which takes values from a provided array.
Definition: WebRequest.php:1275
$request
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled also a ContextSource error or success you ll probably need to make sure the header is varied on WebRequest $request
Definition: hooks.txt:1961
RepoGroup\singleton
static singleton()
Get a RepoGroup instance.
Definition: RepoGroup.php:53
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
UploadStashTest\tearDown
tearDown()
Definition: UploadStashTest.php:41
UploadStashTest\setUp
setUp()
Definition: UploadStashTest.php:18
UploadStash
UploadStash is intended to accomplish a few things:
Definition: UploadStash.php:44
TestUser
Wraps the user object, so we can also retain full access to properties like password if we log in via...
Definition: TestUser.php:6
UploadStashTest\$users
static $users
Definition: UploadStashTest.php:12
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:302
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
UploadStashTest\testValidRequestWithValidRequests
testValidRequestWithValidRequests( $request)
@dataProvider provideValidRequests
Definition: UploadStashTest.php:102
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
user
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Definition: distributors.txt:9
UploadStashTest\provideInvalidRequests
provideInvalidRequests()
Definition: UploadStashTest.php:70
UploadStashTest\$bug29408File
string $bug29408File
Definition: UploadStashTest.php:16
UploadFromStash\isValidRequest
static isValidRequest( $request)
Definition: UploadFromStash.php:83
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
UploadStashTest
@group Database
Definition: UploadStashTest.php:8
UploadStashTest\testValidRequestWithInvalidRequests
testValidRequestWithInvalidRequests( $request)
@dataProvider provideInvalidRequests
Definition: UploadStashTest.php:82
UploadStashTest\provideValidRequests
provideValidRequests()
Definition: UploadStashTest.php:86