Update v1.0.6.5
This commit is contained in:
@@ -56,6 +56,23 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($tdispatcher->hasListeners('foo'));
|
||||
}
|
||||
|
||||
public function testGetListenerPriority()
|
||||
{
|
||||
$dispatcher = new EventDispatcher();
|
||||
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
|
||||
|
||||
$tdispatcher->addListener('foo', function () {}, 123);
|
||||
|
||||
$listeners = $dispatcher->getListeners('foo');
|
||||
$this->assertSame(123, $tdispatcher->getListenerPriority('foo', $listeners[0]));
|
||||
|
||||
// Verify that priority is preserved when listener is removed and re-added
|
||||
// in preProcess() and postProcess().
|
||||
$tdispatcher->dispatch('foo', new Event());
|
||||
$listeners = $dispatcher->getListeners('foo');
|
||||
$this->assertSame(123, $tdispatcher->getListenerPriority('foo', $listeners[0]));
|
||||
}
|
||||
|
||||
public function testAddRemoveSubscriber()
|
||||
{
|
||||
$dispatcher = new EventDispatcher();
|
||||
@@ -138,12 +155,12 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$dispatcher = new EventDispatcher();
|
||||
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
|
||||
$tdispatcher->addListener('foo', $listener1 = function () use (&$called) { $called[] = 'foo1'; });
|
||||
$tdispatcher->addListener('foo', $listener2 = function () use (&$called) { $called[] = 'foo2'; });
|
||||
$tdispatcher->addListener('foo', function () use (&$called) { $called[] = 'foo1'; }, 10);
|
||||
$tdispatcher->addListener('foo', function () use (&$called) { $called[] = 'foo2'; }, 20);
|
||||
|
||||
$tdispatcher->dispatch('foo');
|
||||
|
||||
$this->assertEquals(array('foo1', 'foo2'), $called);
|
||||
$this->assertSame(array('foo2', 'foo1'), $called);
|
||||
}
|
||||
|
||||
public function testDispatchNested()
|
||||
|
Reference in New Issue
Block a user