[EventDispatcher] Clear orphaned events on TraceableEventDispatcher::reset
This commit is contained in:
parent
a552e849d5
commit
d3260dfdcd
@ -217,6 +217,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
|
||||
public function reset()
|
||||
{
|
||||
$this->called = array();
|
||||
$this->orphanedEvents = array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -271,6 +271,17 @@ class TraceableEventDispatcherTest extends TestCase
|
||||
|
||||
$this->assertCount(1, $eventDispatcher->getListeners('foo'), 'expected listener1 to be removed');
|
||||
}
|
||||
|
||||
public function testClearOrphanedEvents()
|
||||
{
|
||||
$tdispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch());
|
||||
$tdispatcher->dispatch('foo');
|
||||
$events = $tdispatcher->getOrphanedEvents();
|
||||
$this->assertCount(1, $events);
|
||||
$tdispatcher->reset();
|
||||
$events = $tdispatcher->getOrphanedEvents();
|
||||
$this->assertCount(0, $events);
|
||||
}
|
||||
}
|
||||
|
||||
class EventSubscriber implements EventSubscriberInterface
|
||||
|
Reference in New Issue
Block a user