[EventDispatcher] check for method to exist
This commit is contained in:
parent
e4816def29
commit
78ae2adb5b
@ -104,6 +104,10 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
|
|||||||
*/
|
*/
|
||||||
public function getListenerPriority($eventName, $listener)
|
public function getListenerPriority($eventName, $listener)
|
||||||
{
|
{
|
||||||
|
if (!method_exists($this->dispatcher, 'getListenerPriority')) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->dispatcher->getListenerPriority($eventName, $listener);
|
return $this->dispatcher->getListenerPriority($eventName, $listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +73,16 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertSame(123, $tdispatcher->getListenerPriority('foo', $listeners[0]));
|
$this->assertSame(123, $tdispatcher->getListenerPriority('foo', $listeners[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetListenerPriorityReturnsZeroWhenWrappedMethodDoesNotExist()
|
||||||
|
{
|
||||||
|
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
|
||||||
|
$traceableEventDispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
|
||||||
|
$traceableEventDispatcher->addListener('foo', function () {}, 123);
|
||||||
|
$listeners = $traceableEventDispatcher->getListeners('foo');
|
||||||
|
|
||||||
|
$this->assertSame(0, $traceableEventDispatcher->getListenerPriority('foo', $listeners[0]));
|
||||||
|
}
|
||||||
|
|
||||||
public function testAddRemoveSubscriber()
|
public function testAddRemoveSubscriber()
|
||||||
{
|
{
|
||||||
$dispatcher = new EventDispatcher();
|
$dispatcher = new EventDispatcher();
|
||||||
|
Reference in New Issue
Block a user