Core and composer updates
This commit is contained in:
parent
a82634bb98
commit
62cac30480
1118 changed files with 21770 additions and 6306 deletions
|
@ -105,7 +105,7 @@ class ContainerAwareEventDispatcher extends EventDispatcher
|
|||
public function hasListeners($eventName = null)
|
||||
{
|
||||
if (null === $eventName) {
|
||||
return (bool) count($this->listenerIds) || (bool) count($this->listeners);
|
||||
return $this->listenerIds || $this->listeners || parent::hasListeners();
|
||||
}
|
||||
|
||||
if (isset($this->listenerIds[$eventName])) {
|
||||
|
|
|
@ -306,6 +306,12 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
|
|||
'event' => $eventName,
|
||||
'priority' => $this->getListenerPriority($eventName, $listener),
|
||||
);
|
||||
|
||||
// unwrap for correct listener info
|
||||
if ($listener instanceof WrappedListener) {
|
||||
$listener = $listener->getWrappedListener();
|
||||
}
|
||||
|
||||
if ($listener instanceof \Closure) {
|
||||
$info += array(
|
||||
'type' => 'Closure',
|
||||
|
|
|
@ -56,6 +56,7 @@ abstract class AbstractEventDispatcherTest extends TestCase
|
|||
{
|
||||
$this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
|
||||
$this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
|
||||
$this->assertTrue($this->dispatcher->hasListeners());
|
||||
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
||||
$this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
|
||||
$this->assertCount(1, $this->dispatcher->getListeners(self::preFoo));
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Symfony\Component\EventDispatcher\Tests\Debug;
|
|||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\Debug\WrappedListener;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
|
@ -100,21 +101,41 @@ class TraceableEventDispatcherTest extends TestCase
|
|||
$this->assertCount(0, $dispatcher->getListeners('foo'));
|
||||
}
|
||||
|
||||
public function testGetCalledListeners()
|
||||
/**
|
||||
* @dataProvider isWrappedDataProvider
|
||||
*
|
||||
* @param bool $isWrapped
|
||||
*/
|
||||
public function testGetCalledListeners($isWrapped)
|
||||
{
|
||||
$dispatcher = new EventDispatcher();
|
||||
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
|
||||
$tdispatcher->addListener('foo', $listener = function () {});
|
||||
$stopWatch = new Stopwatch();
|
||||
$tdispatcher = new TraceableEventDispatcher($dispatcher, $stopWatch);
|
||||
|
||||
$listener = function () {};
|
||||
if ($isWrapped) {
|
||||
$listener = new WrappedListener($listener, 'foo', $stopWatch, $dispatcher);
|
||||
}
|
||||
|
||||
$tdispatcher->addListener('foo', $listener, 5);
|
||||
|
||||
$this->assertEquals(array(), $tdispatcher->getCalledListeners());
|
||||
$this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure', 'priority' => 0)), $tdispatcher->getNotCalledListeners());
|
||||
$this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure', 'priority' => 5)), $tdispatcher->getNotCalledListeners());
|
||||
|
||||
$tdispatcher->dispatch('foo');
|
||||
|
||||
$this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure', 'priority' => null)), $tdispatcher->getCalledListeners());
|
||||
$this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure', 'priority' => 5)), $tdispatcher->getCalledListeners());
|
||||
$this->assertEquals(array(), $tdispatcher->getNotCalledListeners());
|
||||
}
|
||||
|
||||
public function isWrappedDataProvider()
|
||||
{
|
||||
return array(
|
||||
array(false),
|
||||
array(true),
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetCalledListenersNested()
|
||||
{
|
||||
$tdispatcher = null;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
failOnRisky="true"
|
||||
failOnWarning="true"
|
||||
>
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1" />
|
||||
|
|
Reference in a new issue