No Description

EventTest.php 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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->dispatcher = 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 testLegacySetDispatcher()
  54. {
  55. $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
  56. $this->event->setDispatcher($this->dispatcher);
  57. $this->assertSame($this->dispatcher, $this->event->getDispatcher());
  58. }
  59. public function testLegacyGetDispatcher()
  60. {
  61. $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
  62. $this->assertNull($this->event->getDispatcher());
  63. }
  64. public function testLegacyGetName()
  65. {
  66. $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
  67. $this->assertNull($this->event->getName());
  68. }
  69. public function testLegacySetName()
  70. {
  71. $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
  72. $this->event->setName('foo');
  73. $this->assertEquals('foo', $this->event->getName());
  74. }
  75. }