@@ -74,6 +74,20 @@ public function testGetListenerPriority()
74
74
$ this ->assertSame (123 , $ tdispatcher ->getListenerPriority ('foo ' , $ listeners [0 ]));
75
75
}
76
76
77
+ public function testGetListenerPriorityWhileDispatching ()
78
+ {
79
+ $ tdispatcher = new TraceableEventDispatcher (new EventDispatcher (), new Stopwatch ());
80
+ $ priorityWhileDispatching = null ;
81
+
82
+ $ listener = function () use ($ tdispatcher , &$ priorityWhileDispatc
B38B
hing , &$ listener ) {
83
+ $ priorityWhileDispatching = $ tdispatcher ->getListenerPriority ('bar ' , $ listener );
84
+ };
85
+
86
+ $ tdispatcher ->addListener ('bar ' , $ listener , 5 );
87
+ $ tdispatcher ->dispatch ('bar ' );
88
+ $ this ->assertSame (5 , $ priorityWhileDispatching );
89
+ }
90
+
77
91
public function testAddRemoveSubscriber ()
78
92
{
79
93
$ dispatcher = new EventDispatcher ();
@@ -107,7 +121,7 @@ public function testGetCalledListeners()
107
121
$ listeners = $ tdispatcher ->getCalledListeners ();
108
122
$ this ->assertArrayHasKey ('data ' , $ listeners ['foo.closure ' ]);
109
123
unset($ listeners ['foo.closure ' ]['data ' ]);
110
- $ this ->assertEquals (array ('foo.closure ' => array ('event ' => 'foo ' , 'pretty ' => 'closure ' , 'priority ' => null )), $ listeners );
124
+ $ this ->assertEquals (array ('foo.closure ' => array ('event ' => 'foo ' , 'pretty ' => 'closure ' , 'priority ' => 0 )), $ listeners );
111
125
$ this ->assertEquals (array (), $ tdispatcher ->getNotCalledListeners ());
112
126
}
113
127
0 commit comments