wiki.techinc.nl/tests/phpunit/includes/upload/UploadStashTest.php
addshore 959bc315f2 MediaWikiTestCase to MediaWikiIntegrationTestCase
The name change happened some time ago, and I think its
about time to start using the name name!
(Done with a find and replace)

My personal motivation for doing this is that I have started
trying out vscode as an IDE for mediawiki development, and
right now it doesn't appear to handle php aliases very well
or at all.

Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
2020-06-30 17:02:22 +01:00

77 lines
1.7 KiB
PHP

<?php
/**
* @group Database
*
* @covers UploadStash
*/
class UploadStashTest extends MediaWikiIntegrationTestCase {
/**
* @var TestUser[] Array of UploadStashTestUser
*/
public static $users;
/**
* @var string
*/
private $tmpFile;
protected function setUp() : void {
parent::setUp();
$this->tmpFile = $this->getNewTempFile();
file_put_contents( $this->tmpFile, "\x00" );
self::$users = [
'sysop' => new TestUser(
'Uploadstashtestsysop',
'Upload Stash Test Sysop',
'upload_stash_test_sysop@example.com',
[ 'sysop' ]
),
'uploader' => new TestUser(
'Uploadstashtestuser',
'Upload Stash Test User',
'upload_stash_test_user@example.com',
[]
)
];
}
public static function provideInvalidRequests() {
return [
'Check failure on bad wpFileKey' =>
[ new FauxRequest( [ 'wpFileKey' => 'foo' ] ) ],
'Check failure on bad wpSessionKey' =>
[ new FauxRequest( [ 'wpSessionKey' => 'foo' ] ) ],
];
}
/**
* @dataProvider provideInvalidRequests
*/
public function testValidRequestWithInvalidRequests( $request ) {
$this->assertFalse( UploadFromStash::isValidRequest( $request ) );
}
public static function provideValidRequests() {
return [
'Check good wpFileKey' =>
[ new FauxRequest( [ 'wpFileKey' => 'testkey-test.test' ] ) ],
'Check good wpSessionKey' =>
[ new FauxRequest( [ 'wpFileKey' => 'testkey-test.test' ] ) ],
'Check key precedence' =>
[ new FauxRequest( [
'wpFileKey' => 'testkey-test.test',
'wpSessionKey' => 'foo'
] ) ],
];
}
/**
* @dataProvider provideValidRequests
*/
public function testValidRequestWithValidRequests( $request ) {
$this->assertTrue( UploadFromStash::isValidRequest( $request ) );
}
}