aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php')
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php106
1 files changed, 0 insertions, 106 deletions
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}