Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
TestEventSubscriberWithMultipleListeners example
$eventSubscriber
=
new
TestEventSubscriberWithPriorities
(
)
;
$this
->dispatcher->
addSubscriber
(
$eventSubscriber
)
;
$listeners
=
$this
->dispatcher->
getListeners
(
'pre.foo'
)
;
$this
->
assertTrue
(
$this
->dispatcher->
hasListeners
(
self::PREFOO
)
)
;
$this
->
assertCount
(
2,
$listeners
)
;
$this
->
assertInstanceOf
(
TestEventSubscriberWithPriorities::
class
,
$listeners
[
0
]
[
0
]
)
;
}
public
function
testAddSubscriberWithMultipleListeners
(
)
{
$eventSubscriber
=
new
TestEventSubscriberWithMultipleListeners
(
)
;
$this
->dispatcher->
addSubscriber
(
$eventSubscriber
)
;
$listeners
=
$this
->dispatcher->
getListeners
(
'pre.foo'
)
;
$this
->
assertTrue
(
$this
->dispatcher->
hasListeners
(
self::PREFOO
)
)
;
$this
->
assertCount
(
2,
$listeners
)
;
$this
->
assertEquals
(
'preFoo2',
$listeners
[
0
]
[
1
]
)
;
}
public
function
testRemoveSubscriber
(
)
{
$eventSubscriber
=
new
TestEventSubscriber
(
)
;
$this
->dispatcher->
addSubscriber
(
$eventSubscriber
)
;
$eventSubscriber
=
new
TestEventSubscriberWithPriorities
(
)
;
$this
->dispatcher->
addSubscriber
(
$eventSubscriber
)
;
$listeners
=
$this
->dispatcher->
getListeners
(
'pre.foo'
)
;
$this
->
assertTrue
(
$this
->dispatcher->
hasListeners
(
self::preFoo
)
)
;
$this
->
assertCount
(
2,
$listeners
)
;
$this
->
assertInstanceOf
(
TestEventSubscriberWithPriorities::
class
,
$listeners
[
0
]
[
0
]
)
;
}
public
function
testAddSubscriberWithMultipleListeners
(
)
{
$eventSubscriber
=
new
TestEventSubscriberWithMultipleListeners
(
)
;
$this
->dispatcher->
addSubscriber
(
$eventSubscriber
)
;
$listeners
=
$this
->dispatcher->
getListeners
(
'pre.foo'
)
;
$this
->
assertTrue
(
$this
->dispatcher->
hasListeners
(
self::preFoo
)
)
;
$this
->
assertCount
(
2,
$listeners
)
;
$this
->
assertEquals
(
'preFoo2',
$listeners
[
0
]
[
1
]
)
;
}
public
function
testRemoveSubscriber
(
)
{
$eventSubscriber
=
new
TestEventSubscriber
(
)
;