EventTest.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\EventDispatcher\Tests;
  11. use Symfony\Component\EventDispatcher\Event;
  12. use Symfony\Component\EventDispatcher\EventDispatcher;
  13. /**
  14. * Test class for Event.
  15. */
  16. class EventTest extends \PHPUnit_Framework_TestCase
  17. {
  18. /**
  19. * @var \Symfony\Component\EventDispatcher\Event
  20. */
  21. protected $event;
  22. /**
  23. * @var \Symfony\Component\EventDispatcher\EventDispatcher
  24. */
  25. protected $dispatcher;
  26. /**
  27. * Sets up the fixture, for example, opens a network connection.
  28. * This method is called before a test is executed.
  29. */
  30. protected function setUp()
  31. {
  32. $this->event = new Event;
  33. $this->dispatcher = new EventDispatcher();
  34. }
  35. /**
  36. * Tears down the fixture, for example, closes a network connection.
  37. * This method is called after a test is executed.
  38. */
  39. protected function tearDown()
  40. {
  41. $this->event = null;
  42. $this->eventDispatcher = null;
  43. }
  44. public function testIsPropagationStopped()
  45. {
  46. $this->assertFalse($this->event->isPropagationStopped());
  47. }
  48. public function testStopPropagationAndIsPropagationStopped()
  49. {
  50. $this->event->stopPropagation();
  51. $this->assertTrue($this->event->isPropagationStopped());
  52. }
  53. public function testSetDispatcher()
  54. {
  55. $this->event->setDispatcher($this->dispatcher);
  56. $this->assertSame($this->dispatcher, $this->event->getDispatcher());
  57. }
  58. public function testGetDispatcher()
  59. {
  60. $this->assertNull($this->event->getDispatcher());
  61. }
  62. public function testGetName()
  63. {
  64. $this->assertNull($this->event->getName());
  65. }
  66. public function testSetName()
  67. {
  68. $this->event->setName('foo');
  69. $this->assertEquals('foo', $this->event->getName());
  70. }
  71. }