]>
Commit | Line | Data |
---|---|---|
4f5b44bd NL |
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 | ||
12 | namespace Symfony\Component\EventDispatcher\Tests; | |
13 | ||
14 | use Symfony\Component\EventDispatcher\Event; | |
15 | use Symfony\Component\EventDispatcher\EventDispatcher; | |
16 | ||
17 | /** | |
18 | * Test class for Event. | |
19 | */ | |
20 | class 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 | } |