4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\EventDispatcher\Tests;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\EventDispatcher\Event;
16 use Symfony\Component\EventDispatcher\EventDispatcher;
19 * Test class for Event.
21 class EventTest extends TestCase
24 * @var \Symfony\Component\EventDispatcher\Event
29 * @var \Symfony\Component\EventDispatcher\EventDispatcher
31 protected $dispatcher;
34 * Sets up the fixture, for example, opens a network connection.
35 * This method is called before a test is executed.
37 protected function setUp()
39 $this->event = new Event();
40 $this->dispatcher = new EventDispatcher();
44 * Tears down the fixture, for example, closes a network connection.
45 * This method is called after a test is executed.
47 protected function tearDown()
50 $this->dispatcher = null;
53 public function testIsPropagationStopped()
55 $this->assertFalse($this->event->isPropagationStopped());
58 public function testStopPropagationAndIsPropagationStopped()
60 $this->event->stopPropagation();
61 $this->assertTrue($this->event->isPropagationStopped());
67 public function testLegacySetDispatcher()
69 $this->event->setDispatcher($this->dispatcher);
70 $this->assertSame($this->dispatcher, $this->event->getDispatcher());
76 public function testLegacyGetDispatcher()
78 $this->assertNull($this->event->getDispatcher());
84 public function testLegacyGetName()
86 $this->assertNull($this->event->getName());
92 public function testLegacySetName()
94 $this->event->setName('foo');
95 $this->assertEquals('foo', $this->event->getName());