|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 | 15 | use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
|
| 16 | +use Symfony\Component\EventDispatcher\Debug\WrappedListener; |
16 | 17 | use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
17 | 18 | use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
18 | 19 | use Symfony\Component\EventDispatcher\EventDispatcher;
|
@@ -100,21 +101,41 @@ public function testAddRemoveSubscriber()
|
100 | 101 | $this->assertCount(0, $dispatcher->getListeners('foo'));
|
101 | 102 | }
|
102 | 103 |
|
103 |
| - public function testGetCalledListeners() |
| 104 | + /** |
| 105 | + * @dataProvider isWrappedDataProvider |
| 106 | + * |
| 107 | + * @param bool $isWrapped |
| 108 | + */ |
| 109 | + public function testGetCalledListeners($isWrapped) |
104 | 110 | {
|
105 | 111 | $dispatcher = new EventDispatcher();
|
106 |
| - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); |
107 |
| - $tdispatcher->addListener('foo', $listener = function () {}); |
| 112 | + $stopWatch = new Stopwatch(); |
| 113 | + $tdispatcher = new TraceableEventDispatcher($dispatcher, $stopWatch); |
| 114 | + |
| 115 | + $listener = function () {}; |
| 116 | + if ($isWrapped) { |
| 117 | + $listener = new WrappedListener($listener, 'foo', $stopWatch, $dispatcher); |
| 118 | + } |
| 119 | + |
| 120 | + $tdispatcher->addListener('foo', $listener, 5); |
108 | 121 |
|
109 | 122 | $this->assertEquals(array(), $tdispatcher->getCalledListeners());
|
110 |
| - $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure', 'priority' => 0)), $tdispatcher->getNotCalledListeners()); |
| 123 | + $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure', 'priority' => 5)), $tdispatcher->getNotCalledListeners()); |
111 | 124 |
|
112 | 125 | $tdispatcher->dispatch('foo');
|
113 | 126 |
|
114 |
| - $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure', 'priority' => null)), $tdispatcher->getCalledListeners()); |
| 127 | + $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure', 'priority' => 5)), $tdispatcher->getCalledListeners()); |
115 | 128 | $this->assertEquals(array(), $tdispatcher->getNotCalledListeners());
|
116 | 129 | }
|
117 | 130 |
|
| 131 | + public function isWrappedDataProvider() |
| 132 | + { |
| 133 | + return array( |
| 134 | + array(false), |
| 135 | + array(true), |
| 136 | + ); |
| 137 | + } |
| 138 | + |
118 | 139 | public function testGetCalledListenersNested()
|
119 | 140 | {
|
120 | 141 | $tdispatcher = null;
|
|
0 commit comments