Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
EventSubscriber example
$tdispatcher
->
addListener
(
'bar',
$listener
, 5
)
;
$tdispatcher
->
dispatch
(
new
Event
(
)
, 'bar'
)
;
$this
->
assertSame
(
5,
$priorityWhileDispatching
)
;
}
public
function
testAddRemoveSubscriber
(
)
{
$dispatcher
=
new
EventDispatcher
(
)
;
$tdispatcher
=
new
TraceableEventDispatcher
(
$dispatcher
,
new
Stopwatch
(
)
)
;
$subscriber
=
new
EventSubscriber
(
)
;
$tdispatcher
->
addSubscriber
(
$subscriber
)
;
$listeners
=
$dispatcher
->
getListeners
(
'foo'
)
;
$this
->
assertCount
(
1,
$listeners
)
;
$this
->
assertSame
(
[
$subscriber
, 'call'
]
,
$listeners
[
0
]
)
;
$tdispatcher
->
removeSubscriber
(
$subscriber
)
;
$this
->
assertCount
(
0,
$dispatcher
->
getListeners
(
'foo'
)
)
;
}
public
function
testGetCalledListeners
(
)
{