Skip to content

Commit 51bcdb8

Browse files
author
mlievertz
committed
[Event Dispatcher] fixed 29703: TraceableEventDispatcher reset now sets callStack to null with test to dispatch after reset.
1 parent 7448d85 commit 51bcdb8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public function getNotCalledListeners()
221221

222222
public function reset()
223223
{
224-
$this->callStack = array();
224+
$this->callStack = null;
225225
}
226226

227227
/**

src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ public function testClearCalledListeners()
139139
$this->assertEquals(array(array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
140140
}
141141

142+
public function testDispatchAfterReset()
143+
{
144+
$tdispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch());
145+
$tdispatcher->addListener('foo', function () {}, 5);
146+
147+
$tdispatcher->reset();
148+
$tdispatcher->dispatch('foo');
149+
150+
$listeners = $tdispatcher->getCalledListeners();
151+
$this->assertArrayHasKey('stub', $listeners[0]);
152+
}
153+
142154
public function testGetCalledListenersNested()
143155
{
144156
$tdispatcher = null;

0 commit comments

Comments
 (0)