Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
onSessionUsage example
$requestStack
->
push
(
$subRequest
=
new
Request
(
)
)
;
$subRequest
->
setSession
(
$session
)
;
$collector
=
$this
->
createMock
(
RequestDataCollector::
class
)
;
$collector
->
expects
(
$this
->
once
(
)
)
->
method
(
'collectSessionUsage'
)
;
$container
=
new
Container
(
)
;
$container
->
set
(
'request_stack',
$requestStack
)
;
$container
->
set
(
'session_collector',
$collector
->
collectSessionUsage
(
...
)
)
;
$this
->
expectException
(
UnexpectedSessionUsageException::
class
)
;
(
new
SessionListener
(
$container
, true
)
)
->
onSessionUsage
(
)
;
}
public
function
testSessionUsageCallbackWhenNoDebug
(
)
{
$session
=
$this
->
createMock
(
Session::
class
)
;
$session
->
method
(
'isStarted'
)
->
willReturn
(
true
)
;
$session
->
expects
(
$this
->
exactly
(
0
)
)
->
method
(
'save'
)
;
$request
=
new
Request
(
)
;
$request
->attributes->
set
(
'_stateless', true
)
;