Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/event-dispatcher/Tests/Debug/TraceableEventDispatcherTest.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
11:bfffd8d7479a | 12:7a779792577d |
---|---|
11 | 11 |
12 namespace Symfony\Component\EventDispatcher\Tests\Debug; | 12 namespace Symfony\Component\EventDispatcher\Tests\Debug; |
13 | 13 |
14 use PHPUnit\Framework\TestCase; | 14 use PHPUnit\Framework\TestCase; |
15 use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher; | 15 use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher; |
16 use Symfony\Component\EventDispatcher\Debug\WrappedListener; | |
17 use Symfony\Component\EventDispatcher\EventDispatcherInterface; | 16 use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
18 use Symfony\Component\EventDispatcher\EventSubscriberInterface; | 17 use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
19 use Symfony\Component\EventDispatcher\EventDispatcher; | 18 use Symfony\Component\EventDispatcher\EventDispatcher; |
20 use Symfony\Component\EventDispatcher\Event; | 19 use Symfony\Component\EventDispatcher\Event; |
21 use Symfony\Component\Stopwatch\Stopwatch; | 20 use Symfony\Component\Stopwatch\Stopwatch; |
103 | 102 |
104 $tdispatcher->removeSubscriber($subscriber); | 103 $tdispatcher->removeSubscriber($subscriber); |
105 $this->assertCount(0, $dispatcher->getListeners('foo')); | 104 $this->assertCount(0, $dispatcher->getListeners('foo')); |
106 } | 105 } |
107 | 106 |
108 /** | 107 public function testGetCalledListeners() |
109 * @dataProvider isWrappedDataProvider | 108 { |
110 * | 109 $tdispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); |
111 * @param bool $isWrapped | 110 $tdispatcher->addListener('foo', function () {}, 5); |
112 */ | |
113 public function testGetCalledListeners($isWrapped) | |
114 { | |
115 $dispatcher = new EventDispatcher(); | |
116 $stopWatch = new Stopwatch(); | |
117 $tdispatcher = new TraceableEventDispatcher($dispatcher, $stopWatch); | |
118 | |
119 $listener = function () {}; | |
120 | |
121 $tdispatcher->addListener('foo', $listener, 5); | |
122 | 111 |
123 $listeners = $tdispatcher->getNotCalledListeners(); | 112 $listeners = $tdispatcher->getNotCalledListeners(); |
124 $this->assertArrayHasKey('data', $listeners['foo.closure']); | 113 $this->assertArrayHasKey('data', $listeners['foo.closure']); |
125 unset($listeners['foo.closure']['data']); | 114 unset($listeners['foo.closure']['data']); |
126 $this->assertEquals(array(), $tdispatcher->getCalledListeners()); | 115 $this->assertEquals(array(), $tdispatcher->getCalledListeners()); |
130 | 119 |
131 $listeners = $tdispatcher->getCalledListeners(); | 120 $listeners = $tdispatcher->getCalledListeners(); |
132 unset($listeners['foo.closure']['data']); | 121 unset($listeners['foo.closure']['data']); |
133 $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners); | 122 $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners); |
134 $this->assertEquals(array(), $tdispatcher->getNotCalledListeners()); | 123 $this->assertEquals(array(), $tdispatcher->getNotCalledListeners()); |
135 } | |
136 | |
137 public function isWrappedDataProvider() | |
138 { | |
139 return array( | |
140 array(false), | |
141 array(true), | |
142 ); | |
143 } | 124 } |
144 | 125 |
145 public function testGetCalledListenersNested() | 126 public function testGetCalledListenersNested() |
146 { | 127 { |
147 $tdispatcher = null; | 128 $tdispatcher = null; |