aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-04 17:50:34 +0200
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-04 17:50:34 +0200
commit46b77928f746a4231d064774b5b67fd892c7ce86 (patch)
treee3ea690b3f0def1744ddae758923cf92171ef985 /vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests
parent68abd9c71b1d2f7bb2e9d21819584d1d15005b25 (diff)
downloadwallabag-46b77928f746a4231d064774b5b67fd892c7ce86.tar.gz
wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.tar.zst
wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.zip
rm vendor
Diffstat (limited to 'vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests')
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php257
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php320
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php84
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php140
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php106
5 files changed, 0 insertions, 907 deletions
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
deleted file mode 100644
index 71f3ad05..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
+++ /dev/null
@@ -1,257 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\EventDispatcher\Tests;
13
14use Symfony\Component\DependencyInjection\Container;
15use Symfony\Component\DependencyInjection\Scope;
16use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
17use Symfony\Component\EventDispatcher\Event;
18use Symfony\Component\EventDispatcher\EventSubscriberInterface;
19
20class ContainerAwareEventDispatcherTest extends \PHPUnit_Framework_TestCase
21{
22 protected function setUp()
23 {
24 if (!class_exists('Symfony\Component\DependencyInjection\Container')) {
25 $this->markTestSkipped('The "DependencyInjection" component is not available');
26 }
27 }
28
29 public function testAddAListenerService()
30 {
31 $event = new Event();
32
33 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
34
35 $service
36 ->expects($this->once())
37 ->method('onEvent')
38 ->with($event)
39 ;
40
41 $container = new Container();
42 $container->set('service.listener', $service);
43
44 $dispatcher = new ContainerAwareEventDispatcher($container);
45 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
46
47 $dispatcher->dispatch('onEvent', $event);
48 }
49
50 public function testAddASubscriberService()
51 {
52 $event = new Event();
53
54 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\SubscriberService');
55
56 $service
57 ->expects($this->once())
58 ->method('onEvent')
59 ->with($event)
60 ;
61
62 $container = new Container();
63 $container->set('service.subscriber', $service);
64
65 $dispatcher = new ContainerAwareEventDispatcher($container);
66 $dispatcher->addSubscriberService('service.subscriber', 'Symfony\Component\EventDispatcher\Tests\SubscriberService');
67
68 $dispatcher->dispatch('onEvent', $event);
69 }
70
71 public function testPreventDuplicateListenerService()
72 {
73 $event = new Event();
74
75 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
76
77 $service
78 ->expects($this->once())
79 ->method('onEvent')
80 ->with($event)
81 ;
82
83 $container = new Container();
84 $container->set('service.listener', $service);
85
86 $dispatcher = new ContainerAwareEventDispatcher($container);
87 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'), 5);
88 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'), 10);
89
90 $dispatcher->dispatch('onEvent', $event);
91 }
92
93 /**
94 * @expectedException \InvalidArgumentException
95 */
96 public function testTriggerAListenerServiceOutOfScope()
97 {
98 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
99
100 $scope = new Scope('scope');
101 $container = new Container();
102 $container->addScope($scope);
103 $container->enterScope('scope');
104
105 $container->set('service.listener', $service, 'scope');
106
107 $dispatcher = new ContainerAwareEventDispatcher($container);
108 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
109
110 $container->leaveScope('scope');
111 $dispatcher->dispatch('onEvent');
112 }
113
114 public function testReEnteringAScope()
115 {
116 $event = new Event();
117
118 $service1 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
119
120 $service1
121 ->expects($this->exactly(2))
122 ->method('onEvent')
123 ->with($event)
124 ;
125
126 $scope = new Scope('scope');
127 $container = new Container();
128 $container->addScope($scope);
129 $container->enterScope('scope');
130
131 $container->set('service.listener', $service1, 'scope');
132
133 $dispatcher = new ContainerAwareEventDispatcher($container);
134 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
135 $dispatcher->dispatch('onEvent', $event);
136
137 $service2 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
138
139 $service2
140 ->expects($this->once())
141 ->method('onEvent')
142 ->with($event)
143 ;
144
145 $container->enterScope('scope');
146 $container->set('service.listener', $service2, 'scope');
147
148 $dispatcher->dispatch('onEvent', $event);
149
150 $container->leaveScope('scope');
151
152 $dispatcher->dispatch('onEvent');
153 }
154
155 public function testHasListenersOnLazyLoad()
156 {
157 $event = new Event();
158
159 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
160
161 $container = new Container();
162 $container->set('service.listener', $service);
163
164 $dispatcher = new ContainerAwareEventDispatcher($container);
165 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
166
167 $event->setDispatcher($dispatcher);
168 $event->setName('onEvent');
169
170 $service
171 ->expects($this->once())
172 ->method('onEvent')
173 ->with($event)
174 ;
175
176 $this->assertTrue($dispatcher->hasListeners());
177
178 if ($dispatcher->hasListeners('onEvent')) {
179 $dispatcher->dispatch('onEvent');
180 }
181 }
182
183 public function testGetListenersOnLazyLoad()
184 {
185 $event = new Event();
186
187 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
188
189 $container = new Container();
190 $container->set('service.listener', $service);
191
192 $dispatcher = new ContainerAwareEventDispatcher($container);
193 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
194
195 $listeners = $dispatcher->getListeners();
196
197 $this->assertTrue(isset($listeners['onEvent']));
198
199 $this->assertCount(1, $dispatcher->getListeners('onEvent'));
200 }
201
202 public function testRemoveAfterDispatch()
203 {
204 $event = new Event();
205
206 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
207
208 $container = new Container();
209 $container->set('service.listener', $service);
210
211 $dispatcher = new ContainerAwareEventDispatcher($container);
212 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
213
214 $dispatcher->dispatch('onEvent', new Event());
215 $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent'));
216 $this->assertFalse($dispatcher->hasListeners('onEvent'));
217 }
218
219 public function testRemoveBeforeDispatch()
220 {
221 $event = new Event();
222
223 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
224
225 $container = new Container();
226 $container->set('service.listener', $service);
227
228 $dispatcher = new ContainerAwareEventDispatcher($container);
229 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
230
231 $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent'));
232 $this->assertFalse($dispatcher->hasListeners('onEvent'));
233 }
234}
235
236class Service
237{
238 public function onEvent(Event $e)
239 {
240 }
241}
242
243class SubscriberService implements EventSubscriberInterface
244{
245 public static function getSubscribedEvents()
246 {
247 return array(
248 'onEvent' => 'onEvent',
249 'onEvent' => array('onEvent', 10),
250 'onEvent' => array('onEvent'),
251 );
252 }
253
254 public function onEvent(Event $e)
255 {
256 }
257}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php
deleted file mode 100644
index ad7e4484..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php
+++ /dev/null
@@ -1,320 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\EventDispatcher\Tests;
13
14use Symfony\Component\EventDispatcher\Event;
15use Symfony\Component\EventDispatcher\EventDispatcher;
16use Symfony\Component\EventDispatcher\EventSubscriberInterface;
17
18class EventDispatcherTest extends \PHPUnit_Framework_TestCase
19{
20 /* Some pseudo events */
21 const preFoo = 'pre.foo';
22 const postFoo = 'post.foo';
23 const preBar = 'pre.bar';
24 const postBar = 'post.bar';
25
26 private $dispatcher;
27
28 private $listener;
29
30 protected function setUp()
31 {
32 $this->dispatcher = new EventDispatcher();
33 $this->listener = new TestEventListener();
34 }
35
36 protected function tearDown()
37 {
38 $this->dispatcher = null;
39 $this->listener = null;
40 }
41
42 public function testInitialState()
43 {
44 $this->assertEquals(array(), $this->dispatcher->getListeners());
45 $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
46 $this->assertFalse($this->dispatcher->hasListeners(self::postFoo));
47 }
48
49 public function testAddListener()
50 {
51 $this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
52 $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
53 $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
54 $this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
55 $this->assertCount(1, $this->dispatcher->getListeners(self::preFoo));
56 $this->assertCount(1, $this->dispatcher->getListeners(self::postFoo));
57 $this->assertCount(2, $this->dispatcher->getListeners());
58 }
59
60 public function testGetListenersSortsByPriority()
61 {
62 $listener1 = new TestEventListener();
63 $listener2 = new TestEventListener();
64 $listener3 = new TestEventListener();
65 $listener1->name = '1';
66 $listener2->name = '2';
67 $listener3->name = '3';
68
69 $this->dispatcher->addListener('pre.foo', array($listener1, 'preFoo'), -10);
70 $this->dispatcher->addListener('pre.foo', array($listener2, 'preFoo'), 10);
71 $this->dispatcher->addListener('pre.foo', array($listener3, 'preFoo'));
72
73 $expected = array(
74 array($listener2, 'preFoo'),
75 array($listener3, 'preFoo'),
76 array($listener1, 'preFoo'),
77 );
78
79 $this->assertSame($expected, $this->dispatcher->getListeners('pre.foo'));
80 }
81
82 public function testGetAllListenersSortsByPriority()
83 {
84 $listener1 = new TestEventListener();
85 $listener2 = new TestEventListener();
86 $listener3 = new TestEventListener();
87 $listener4 = new TestEventListener();
88 $listener5 = new TestEventListener();
89 $listener6 = new TestEventListener();
90
91 $this->dispatcher->addListener('pre.foo', $listener1, -10);
92 $this->dispatcher->addListener('pre.foo', $listener2);
93 $this->dispatcher->addListener('pre.foo', $listener3, 10);
94 $this->dispatcher->addListener('post.foo', $listener4, -10);
95 $this->dispatcher->addListener('post.foo', $listener5);
96 $this->dispatcher->addListener('post.foo', $listener6, 10);
97
98 $expected = array(
99 'pre.foo' => array($listener3, $listener2, $listener1),
100 'post.foo' => array($listener6, $listener5, $listener4),
101 );
102
103 $this->assertSame($expected, $this->dispatcher->getListeners());
104 }
105
106 public function testDispatch()
107 {
108 $this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
109 $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
110 $this->dispatcher->dispatch(self::preFoo);
111 $this->assertTrue($this->listener->preFooInvoked);
112 $this->assertFalse($this->listener->postFooInvoked);
113 $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch('noevent'));
114 $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(self::preFoo));
115 $event = new Event();
116 $return = $this->dispatcher->dispatch(self::preFoo, $event);
117 $this->assertEquals('pre.foo', $event->getName());
118 $this->assertSame($event, $return);
119 }
120
121 public function testDispatchForClosure()
122 {
123 $invoked = 0;
124 $listener = function () use (&$invoked) {
125 $invoked++;
126 };
127 $this->dispatcher->addListener('pre.foo', $listener);
128 $this->dispatcher->addListener('post.foo', $listener);
129 $this->dispatcher->dispatch(self::preFoo);
130 $this->assertEquals(1, $invoked);
131 }
132
133 public function testStopEventPropagation()
134 {
135 $otherListener = new TestEventListener();
136
137 // postFoo() stops the propagation, so only one listener should
138 // be executed
139 // Manually set priority to enforce $this->listener to be called first
140 $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'), 10);
141 $this->dispatcher->addListener('post.foo', array($otherListener, 'preFoo'));
142 $this->dispatcher->dispatch(self::postFoo);
143 $this->assertTrue($this->listener->postFooInvoked);
144 $this->assertFalse($otherListener->postFooInvoked);
145 }
146
147 public function testDispatchByPriority()
148 {
149 $invoked = array();
150 $listener1 = function () use (&$invoked) {
151 $invoked[] = '1';
152 };
153 $listener2 = function () use (&$invoked) {
154 $invoked[] = '2';
155 };
156 $listener3 = function () use (&$invoked) {
157 $invoked[] = '3';
158 };
159 $this->dispatcher->addListener('pre.foo', $listener1, -10);
160 $this->dispatcher->addListener('pre.foo', $listener2);
161 $this->dispatcher->addListener('pre.foo', $listener3, 10);
162 $this->dispatcher->dispatch(self::preFoo);
163 $this->assertEquals(array('3', '2', '1'), $invoked);
164 }
165
166 public function testRemoveListener()
167 {
168 $this->dispatcher->addListener('pre.bar', $this->listener);
169 $this->assertTrue($this->dispatcher->hasListeners(self::preBar));
170 $this->dispatcher->removeListener('pre.bar', $this->listener);
171 $this->assertFalse($this->dispatcher->hasListeners(self::preBar));
172 $this->dispatcher->removeListener('notExists', $this->listener);
173 }
174
175 public function testAddSubscriber()
176 {
177 $eventSubscriber = new TestEventSubscriber();
178 $this->dispatcher->addSubscriber($eventSubscriber);
179 $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
180 $this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
181 }
182
183 public function testAddSubscriberWithPriorities()
184 {
185 $eventSubscriber = new TestEventSubscriber();
186 $this->dispatcher->addSubscriber($eventSubscriber);
187
188 $eventSubscriber = new TestEventSubscriberWithPriorities();
189 $this->dispatcher->addSubscriber($eventSubscriber);
190
191 $listeners = $this->dispatcher->getListeners('pre.foo');
192 $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
193 $this->assertCount(2, $listeners);
194 $this->assertInstanceOf('Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities', $listeners[0][0]);
195 }
196
197 public function testAddSubscriberWithMultipleListeners()
198 {
199 $eventSubscriber = new TestEventSubscriberWithMultipleListeners();
200 $this->dispatcher->addSubscriber($eventSubscriber);
201
202 $listeners = $this->dispatcher->getListeners('pre.foo');
203 $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
204 $this->assertCount(2, $listeners);
205 $this->assertEquals('preFoo2', $listeners[0][1]);
206 }
207
208 public function testRemoveSubscriber()
209 {
210 $eventSubscriber = new TestEventSubscriber();
211 $this->dispatcher->addSubscriber($eventSubscriber);
212 $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
213 $this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
214 $this->dispatcher->removeSubscriber($eventSubscriber);
215 $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
216 $this->assertFalse($this->dispatcher->hasListeners(self::postFoo));
217 }
218
219 public function testRemoveSubscriberWithPriorities()
220 {
221 $eventSubscriber = new TestEventSubscriberWithPriorities();
222 $this->dispatcher->addSubscriber($eventSubscriber);
223 $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
224 $this->dispatcher->removeSubscriber($eventSubscriber);
225 $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
226 }
227
228 public function testRemoveSubscriberWithMultipleListeners()
229 {
230 $eventSubscriber = new TestEventSubscriberWithMultipleListeners();
231 $this->dispatcher->addSubscriber($eventSubscriber);
232 $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
233 $this->assertCount(2, $this->dispatcher->getListeners(self::preFoo));
234 $this->dispatcher->removeSubscriber($eventSubscriber);
235 $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
236 }
237
238 public function testEventReceivesTheDispatcherInstance()
239 {
240 $test = $this;
241 $this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
242 $dispatcher = $event->getDispatcher();
243 });
244 $this->dispatcher->dispatch('test');
245 $this->assertSame($this->dispatcher, $dispatcher);
246 }
247
248 /**
249 * @see https://bugs.php.net/bug.php?id=62976
250 *
251 * This bug affects:
252 * - The PHP 5.3 branch for versions < 5.3.18
253 * - The PHP 5.4 branch for versions < 5.4.8
254 * - The PHP 5.5 branch is not affected
255 */
256 public function testWorkaroundForPhpBug62976()
257 {
258 $dispatcher = new EventDispatcher();
259 $dispatcher->addListener('bug.62976', new CallableClass());
260 $dispatcher->removeListener('bug.62976', function() {});
261 $this->assertTrue($dispatcher->hasListeners('bug.62976'));
262 }
263}
264
265class CallableClass
266{
267 public function __invoke()
268 {
269 }
270}
271
272class TestEventListener
273{
274 public $preFooInvoked = false;
275 public $postFooInvoked = false;
276
277 /* Listener methods */
278
279 public function preFoo(Event $e)
280 {
281 $this->preFooInvoked = true;
282 }
283
284 public function postFoo(Event $e)
285 {
286 $this->postFooInvoked = true;
287
288 $e->stopPropagation();
289 }
290}
291
292class TestEventSubscriber implements EventSubscriberInterface
293{
294 public static function getSubscribedEvents()
295 {
296 return array('pre.foo' => 'preFoo', 'post.foo' => 'postFoo');
297 }
298}
299
300class TestEventSubscriberWithPriorities implements EventSubscriberInterface
301{
302 public static function getSubscribedEvents()
303 {
304 return array(
305 'pre.foo' => array('preFoo', 10),
306 'post.foo' => array('postFoo'),
307 );
308 }
309}
310
311class TestEventSubscriberWithMultipleListeners implements EventSubscriberInterface
312{
313 public static function getSubscribedEvents()
314 {
315 return array('pre.foo' => array(
316 array('preFoo1'),
317 array('preFoo2', 10)
318 ));
319 }
320}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php
deleted file mode 100644
index 52aa9ad6..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php
+++ /dev/null
@@ -1,84 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\EventDispatcher\Tests;
13
14use Symfony\Component\EventDispatcher\Event;
15use Symfony\Component\EventDispatcher\EventDispatcher;
16
17/**
18 * Test class for Event.
19 */
20class EventTest extends \PHPUnit_Framework_TestCase
21{
22 /**
23 * @var \Symfony\Component\EventDispatcher\Event
24 */
25 protected $event;
26
27 /**
28 * @var \Symfony\Component\EventDispatcher\EventDispatcher
29 */
30 protected $dispatcher;
31
32 /**
33 * Sets up the fixture, for example, opens a network connection.
34 * This method is called before a test is executed.
35 */
36 protected function setUp()
37 {
38 $this->event = new Event;
39 $this->dispatcher = new EventDispatcher();
40 }
41
42 /**
43 * Tears down the fixture, for example, closes a network connection.
44 * This method is called after a test is executed.
45 */
46 protected function tearDown()
47 {
48 $this->event = null;
49 $this->eventDispatcher = null;
50 }
51
52 public function testIsPropagationStopped()
53 {
54 $this->assertFalse($this->event->isPropagationStopped());
55 }
56
57 public function testStopPropagationAndIsPropagationStopped()
58 {
59 $this->event->stopPropagation();
60 $this->assertTrue($this->event->isPropagationStopped());
61 }
62
63 public function testSetDispatcher()
64 {
65 $this->event->setDispatcher($this->dispatcher);
66 $this->assertSame($this->dispatcher, $this->event->getDispatcher());
67 }
68
69 public function testGetDispatcher()
70 {
71 $this->assertNull($this->event->getDispatcher());
72 }
73
74 public function testGetName()
75 {
76 $this->assertNull($this->event->getName());
77 }
78
79 public function testSetName()
80 {
81 $this->event->setName('foo');
82 $this->assertEquals('foo', $this->event->getName());
83 }
84}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php
deleted file mode 100644
index 8dd6f5b4..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php
+++ /dev/null
@@ -1,140 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\EventDispatcher\Tests;
13
14use Symfony\Component\EventDispatcher\GenericEvent;
15
16/**
17 * Test class for Event.
18 */
19class GenericEventTest extends \PHPUnit_Framework_TestCase
20{
21
22 /**
23 * @var GenericEvent
24 */
25 private $event;
26
27 private $subject;
28
29 /**
30 * Prepares the environment before running a test.
31 */
32 protected function setUp()
33 {
34 parent::setUp();
35
36 $this->subject = new \StdClass();
37 $this->event = new GenericEvent($this->subject, array('name' => 'Event'), 'foo');
38 }
39
40 /**
41 * Cleans up the environment after running a test.
42 */
43 protected function tearDown()
44 {
45 $this->subject = null;
46 $this->event = null;
47
48 parent::tearDown();
49 }
50
51 public function testConstruct()
52 {
53 $this->assertEquals($this->event, new GenericEvent($this->subject, array('name' => 'Event')));
54 }
55
56 /**
57 * Tests Event->getArgs()
58 */
59 public function testGetArguments()
60 {
61 // test getting all
62 $this->assertSame(array('name' => 'Event'), $this->event->getArguments());
63 }
64
65 public function testSetArguments()
66 {
67 $result = $this->event->setArguments(array('foo' => 'bar'));
68 $this->assertAttributeSame(array('foo' => 'bar'), 'arguments', $this->event);
69 $this->assertSame($this->event, $result);
70 }
71
72 public function testSetArgument()
73 {
74 $result = $this->event->setArgument('foo2', 'bar2');
75 $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event);
76 $this->assertEquals($this->event, $result);
77 }
78
79 public function testGetArgument()
80 {
81 // test getting key
82 $this->assertEquals('Event', $this->event->getArgument('name'));
83 }
84
85 /**
86 * @expectedException \InvalidArgumentException
87 */
88 public function testGetArgException()
89 {
90 $this->event->getArgument('nameNotExist');
91 }
92
93 public function testOffsetGet()
94 {
95 // test getting key
96 $this->assertEquals('Event', $this->event['name']);
97
98 // test getting invalid arg
99 $this->setExpectedException('InvalidArgumentException');
100 $this->assertFalse($this->event['nameNotExist']);
101 }
102
103 public function testOffsetSet()
104 {
105 $this->event['foo2'] = 'bar2';
106 $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event);
107 }
108
109 public function testOffsetUnset()
110 {
111 unset($this->event['name']);
112 $this->assertAttributeSame(array(), 'arguments', $this->event);
113 }
114
115 public function testOffsetIsset()
116 {
117 $this->assertTrue(isset($this->event['name']));
118 $this->assertFalse(isset($this->event['nameNotExist']));
119 }
120
121 public function testHasArgument()
122 {
123 $this->assertTrue($this->event->hasArgument('name'));
124 $this->assertFalse($this->event->hasArgument('nameNotExist'));
125 }
126
127 public function testGetSubject()
128 {
129 $this->assertSame($this->subject, $this->event->getSubject());
130 }
131
132 public function testHasIterator()
133 {
134 $data = array();
135 foreach ($this->event as $key => $value) {
136 $data[$key] = $value;
137 }
138 $this->assertEquals(array('name' => 'Event'), $data);
139 }
140}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
deleted file mode 100644
index 6402f89f..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
+++ /dev/null
@@ -1,106 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\EventDispatcher\Tests;
13
14use Symfony\Component\EventDispatcher\Event;
15use Symfony\Component\EventDispatcher\ImmutableEventDispatcher;
16use Symfony\Component\EventDispatcher\EventSubscriberInterface;
17
18/**
19 * @author Bernhard Schussek <bschussek@gmail.com>
20 */
21class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase
22{
23 /**
24 * @var \PHPUnit_Framework_MockObject_MockObject
25 */
26 private $innerDispatcher;
27
28 /**
29 * @var ImmutableEventDispatcher
30 */
31 private $dispatcher;
32
33 protected function setUp()
34 {
35 $this->innerDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
36 $this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher);
37 }
38
39 public function testDispatchDelegates()
40 {
41 $event = new Event();
42
43 $this->innerDispatcher->expects($this->once())
44 ->method('dispatch')
45 ->with('event', $event)
46 ->will($this->returnValue('result'));
47
48 $this->assertSame('result', $this->dispatcher->dispatch('event', $event));
49 }
50
51 public function testGetListenersDelegates()
52 {
53 $this->innerDispatcher->expects($this->once())
54 ->method('getListeners')
55 ->with('event')
56 ->will($this->returnValue('result'));
57
58 $this->assertSame('result', $this->dispatcher->getListeners('event'));
59 }
60
61 public function testHasListenersDelegates()
62 {
63 $this->innerDispatcher->expects($this->once())
64 ->method('hasListeners')
65 ->with('event')
66 ->will($this->returnValue('result'));
67
68 $this->assertSame('result', $this->dispatcher->hasListeners('event'));
69 }
70
71 /**
72 * @expectedException \BadMethodCallException
73 */
74 public function testAddListenerDisallowed()
75 {
76 $this->dispatcher->addListener('event', function () { return 'foo'; });
77 }
78
79 /**
80 * @expectedException \BadMethodCallException
81 */
82 public function testAddSubscriberDisallowed()
83 {
84 $subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface');
85
86 $this->dispatcher->addSubscriber($subscriber);
87 }
88
89 /**
90 * @expectedException \BadMethodCallException
91 */
92 public function testRemoveListenerDisallowed()
93 {
94 $this->dispatcher->removeListener('event', function () { return 'foo'; });
95 }
96
97 /**
98 * @expectedException \BadMethodCallException
99 */
100 public function testRemoveSubscriberDisallowed()
101 {
102 $subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface');
103
104 $this->dispatcher->removeSubscriber($subscriber);
105 }
106}