\Symfony\Component\HttpFoundation\Session\StorageMockArraySessionStorage

MockArraySessionStorage mocks the session for unit tests.

No PHP session is actually started since a session can be initialized and shutdown only once per PHP execution cycle.

When doing functional testing, you should use MockFileSessionStorage instead.

Summary

Methods
Properties
Constants
__construct()
setSessionData()
start()
regenerate()
getId()
setId()
getName()
setName()
save()
clear()
registerBag()
getBag()
isStarted()
setMetadataBag()
getMetadataBag()
No public properties found
No constants found
generateId()
loadSession()
$id
$name
$started
$closed
$data
$metadataBag
$bags
N/A
No private methods found
No private properties found
N/A

Properties

$id

$id : string

Type

string

$name

$name : string

Type

string

$started

$started : bool

Type

bool

$closed

$closed : bool

Type

bool

$data

$data : array

Type

array

$metadataBag

$metadataBag : \Symfony\Component\HttpFoundation\Session\Storage\MetadataBag

Type

MetadataBag

$bags

$bags : array|\Symfony\Component\HttpFoundation\Session\SessionBagInterface[]

Type

SessionBagInterface[]

Methods

__construct()

__construct(string  $name = 'MOCKSESSID', \Symfony\Component\HttpFoundation\Session\Storage\MetadataBag  $metaBag = null) : mixed

Parameters

string $name
\Symfony\Component\HttpFoundation\Session\Storage\MetadataBag $metaBag

Returns

mixed —

setSessionData()

setSessionData(array  $array) : mixed

Parameters

array $array

Returns

mixed —

start()

start() : bool

Starts the session.

Returns

bool —

regenerate()

regenerate(bool  $destroy = false, int  $lifetime = null) : bool

Regenerates id that represents this storage.

Parameters

bool $destroy

Destroy session when regenerating?

int $lifetime

Sets the cookie lifetime for the session cookie. A null value will leave the system settings unchanged, 0 sets the cookie to expire with browser session. Time is in seconds, and is not a Unix timestamp.

Returns

bool —

getId()

getId() : string

Returns the session ID.

Returns

string —

setId()

setId(string  $id) : mixed

Sets the session ID.

Parameters

string $id

Returns

mixed —

getName()

getName() : string

Returns the session name.

Returns

string —

setName()

setName(string  $name) : mixed

Sets the session name.

Parameters

string $name

Returns

mixed —

save()

save() : mixed

Force the session to be saved and closed.

Returns

mixed —

clear()

clear() : mixed

Clear all session data in memory.

Returns

mixed —

registerBag()

registerBag(\Symfony\Component\HttpFoundation\Session\SessionBagInterface  $bag) : mixed

Registers a SessionBagInterface for use.

Parameters

\Symfony\Component\HttpFoundation\Session\SessionBagInterface $bag

Returns

mixed —

getBag()

getBag(string  $name) : \Symfony\Component\HttpFoundation\Session\SessionBagInterface

Gets a SessionBagInterface by name.

Parameters

string $name

Returns

\Symfony\Component\HttpFoundation\Session\SessionBagInterface —

isStarted()

isStarted() : bool

Checks if the session is started.

Returns

bool —

setMetadataBag()

setMetadataBag(\Symfony\Component\HttpFoundation\Session\Storage\MetadataBag  $bag = null) : mixed

Parameters

\Symfony\Component\HttpFoundation\Session\Storage\MetadataBag $bag

Returns

mixed —

getMetadataBag()

getMetadataBag() : \Symfony\Component\HttpFoundation\Session\Storage\MetadataBag

Gets the MetadataBag.

Returns

\Symfony\Component\HttpFoundation\Session\Storage\MetadataBag —

generateId()

generateId() : string

Generates a session ID.

This doesn't need to be particularly cryptographically secure since this is just a mock.

Returns

string —

loadSession()

loadSession() : mixed

Returns

mixed —