SymfonyComponentHttpFoundationSessionStorageMockArraySessionStorage

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.

File
vendorSymfonyComponentHttpFoundationSessionStorageMockArraySessionStorage.php
Package
Default
Class hierarchy
SymfonyComponentHttpFoundationSessionStorageMockArraySessionStorage
Implements
SymfonyComponentHttpFoundationSessionStorageSessionStorageInterface

Tags

author

Fabien Potencier fabien@symfony.com

Bulat Shakirzyanov mallluhuct@gmail.com

Drak drak@zikula.org

Properties

$id

$id : string

Type

string

Tags

None found

$name

$name : string

Type

string

Tags

None found

$started

$started : boolean

Type

boolean

Tags

None found

$closed

$closed : boolean

Type

boolean

Tags

None found

$data

$data : array

Type

array

Tags

None found

$metadataBag

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

Type

SymfonyComponentHttpFoundationSessionStorageMetadataBag

Tags

None found

$bags

$bags : array

Type

array

Tags

None found

Methods

__construct()

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

Constructor.

Parameters

string $name

Session name

SymfonyComponentHttpFoundationSessionStorageMetadataBag $metaBag

MetadataBag instance.

Tags

None found

setSessionData()

setSessionData(array  $array) 

Sets the session data.

Parameters

array $array

Tags

None found

start()

start() : boolean

Starts the session.

Returns

boolean —

True if started.

Tags

None found

regenerate()

regenerate(Boolean  $destroy = false, integer  $lifetime = null) : Boolean

Regenerates id that represents this storage.

This method must invoke session_regenerate_id($destroy) unless this interface is used for a storage object designed for unit or functional testing where a real PHP session would interfere with testing.

Note regenerate destroy should not clear the session data in memory only delete the session data from persistent storage.

Parameters

Boolean $destroy

Destroy session when regenerating?

integer $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

Boolean —

True if session regenerated, false if error

Tags

None found

getId()

getId() : string

Returns the session ID

Returns

string —

The session ID or empty.

Tags

None found

setId()

setId(string  $id) 

Sets the session ID

Parameters

string $id

Tags

None found

getName()

getName() : mixed

Returns the session name

Returns

mixed —

The session name.

Tags

None found

setName()

setName(string  $name) 

Sets the session name

Parameters

string $name

Tags

None found

save()

save() 

Force the session to be saved and closed.

This method must invoke session_write_close() unless this interface is used for a storage object design for unit or functional testing where a real PHP session would interfere with testing, in which case it it should actually persist the session data if required.

Tags

None found

clear()

clear() 

Clear all session data in memory.

Tags

None found

registerBag()

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

Registers a SessionBagInterface for use.

Parameters

SymfonyComponentHttpFoundationSessionSessionBagInterface $bag

Tags

None found

getBag()

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

Gets a SessionBagInterface by name.

Parameters

string $name

Returns

SymfonyComponentHttpFoundationSessionSessionBagInterface

Tags

None found

isStarted()

isStarted() : boolean

Checks if the session is started.

Returns

boolean —

True if started, false otherwise.

Tags

None found

setMetadataBag()

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

Sets the MetadataBag.

Parameters

SymfonyComponentHttpFoundationSessionStorageMetadataBag $bag

Tags

None found

getMetadataBag()

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

Gets the MetadataBag.

Returns

SymfonyComponentHttpFoundationSessionStorageMetadataBag

Tags

None found

generateId()

generateId() : string

Generates a session ID.

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

Returns

string

Tags

None found

loadSession()

loadSession() 

Tags

None found