wiki.techinc.nl/tests/phpunit/includes/upload/UploadStashTest.php
libraryupgrader 5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00

77 lines
1.7 KiB
PHP

<?php
/**
* @group Database
*
* @covers UploadStash
*/
class UploadStashTest extends MediaWikiIntegrationTestCase {
/**
* @var TestUser[]
*/
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 ) );
}
}