3 namespace MediaWiki\Session
;
10 * BagOStuff with utility functions for MediaWiki\\Session\\* testing
12 class TestBagOStuff
extends CachedBagOStuff
{
14 public function __construct() {
15 parent
::__construct( new HashBagOStuff
);
19 * @param string $id Session ID
20 * @param array $data Session data
22 public function setSessionData( $id, array $data ) {
23 $this->setSession( $id, [ 'data' => $data ] );
27 * @param string $id Session ID
28 * @param array $metadata Session metadata
30 public function setSessionMeta( $id, array $metadata ) {
31 $this->setSession( $id, [ 'metadata' => $metadata ] );
35 * @param string $id Session ID
36 * @param array $blob Session metadata and data
38 public function setSession( $id, array $blob ) {
43 $blob['metadata'] +
= [
47 'provider' => 'DummySessionProvider',
50 $this->setRawSession( $id, $blob );
54 * @param string $id Session ID
55 * @param array|mixed $blob Session metadata and data
57 public function setRawSession( $id, $blob ) {
58 $expiry = RequestContext
::getMain()->getConfig()->get( 'ObjectCacheSessionExpiry' );
59 $this->set( $this->makeKey( 'MWSession', $id ), $blob, $expiry );
63 * @param string $id Session ID
66 public function getSession( $id ) {
67 return $this->get( $this->makeKey( 'MWSession', $id ) );
71 * @param string $id Session ID
74 public function getSessionFromBackend( $id ) {
75 return $this->backend
->get( $this->makeKey( 'MWSession', $id ) );
79 * @param string $id Session ID
81 public function deleteSession( $id ) {
82 $this->delete( $this->makeKey( 'MWSession', $id ) );