Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4118220
SessionHelperTestTrait.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
SessionHelperTestTrait.php
View Options
<?php
namespace
MediaWiki\Tests\Rest\Handler
;
use
MediaWiki\Session\Session
;
use
MediaWiki\Session\SessionId
;
use
MediaWiki\Session\SessionProviderInterface
;
use
PHPUnit\Framework\MockObject\MockObject
;
/**
* A trait for testing Handler classes.
* This trait is intended to be used on subclasses of MediaWikiUnitTestCase
* or MediaWikiIntegrationTestCase.
*
* @stable to use
*/
trait
SessionHelperTestTrait
{
/**
* @param bool $csrfSafe
* @return Session&MockObject
*/
public
function
getSession
(
bool
$csrfSafe
)
{
/** @var SessionProviderInterface&MockObject $session */
$sessionProvider
=
$this
->
createMock
(
SessionProviderInterface
::
class
);
$sessionProvider
->
method
(
'safeAgainstCsrf'
)->
willReturn
(
$csrfSafe
);
/** @var Session&MockObject $session */
$session
=
$this
->
createMock
(
Session
::
class
);
$session
->
method
(
'getSessionId'
)->
willReturn
(
new
SessionId
(
'test'
)
);
$session
->
method
(
'getProvider'
)->
willReturn
(
$sessionProvider
);
$session
->
method
(
'isPersistent'
)->
willReturn
(
true
);
return
$session
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 02:39 (2 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
db/0c/8f4c6d8d7e14a686663aff812eda
Default Alt Text
SessionHelperTestTrait.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment