Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7399258
UploadFromStashTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
UploadFromStashTest.php
View Options
<?php
use
MediaWiki\Request\FauxRequest
;
/**
* @group Database
*
* @covers \UploadFromStash
*/
class
UploadFromStashTest
extends
MediaWikiIntegrationTestCase
{
public
function
testIsValid
()
{
$validKey
=
'aaa.aaa.tmp'
;
$this
->
assertTrue
(
UploadFromStash
::
isValidKey
(
$validKey
)
);
$request
=
new
FauxRequest
(
[
'wpFileKey'
=>
$validKey
],
true
);
$this
->
assertTrue
(
UploadFromStash
::
isValidRequest
(
$request
)
);
$request
=
new
FauxRequest
(
[
'wpSessionKey'
=>
$validKey
],
true
);
$this
->
assertTrue
(
UploadFromStash
::
isValidRequest
(
$request
)
);
}
public
function
testUploadStash
()
{
$user
=
$this
->
getTestUser
()->
getUser
();
$filepath
=
__DIR__
.
'/../../data/media/1bit-png.png'
;
$filename
=
'TestStash.png'
;
// file is removed after upload, provide a copy to allow the delete
$tempFile
=
$this
->
getNewTempFile
();
file_put_contents
(
$tempFile
,
file_get_contents
(
$filepath
)
);
$stash
=
$this
->
getServiceContainer
()->
getRepoGroup
()
->
getLocalRepo
()->
getUploadStash
(
$user
);
$file
=
$stash
->
stashFile
(
$tempFile
,
'image/png'
);
$filekey
=
$file
->
getFileKey
();
$upload
=
new
UploadFromStash
(
$user
);
$upload
->
initialize
(
$filekey
,
$filename
);
$status
=
$upload
->
performUpload
(
'comment'
,
'page'
,
false
,
$user
);
$this
->
assertStatusGood
(
$status
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 21, 15:52 (1 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
bd/19/4c0a53d185988296a82b9747badb
Default Alt Text
UploadFromStashTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment