EventStackTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * CakePHP : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP Project
  12. * @since 3.3.0
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Test\TestCase\Event;
  16. use Cake\Event\Event;
  17. use Cake\Event\EventStack;
  18. use Cake\TestSuite\TestCase;
  19. /**
  20. * Tests the Cake\Event\EvenStack class functionality
  21. */
  22. class EvenStackTest extends TestCase
  23. {
  24. /**
  25. * testAddEventAndFlush
  26. *
  27. * @return void
  28. */
  29. public function testAddEventAndFlush()
  30. {
  31. $eventStack = new EventStack();
  32. $event = new Event('my_event', $this);
  33. $event2 = new Event('my_second_event', $this);
  34. $eventStack->add($event);
  35. $eventStack->add($event2);
  36. $this->assertCount(2, $eventStack);
  37. $this->assertEquals($eventStack[0], $event);
  38. $this->assertEquals($eventStack[1], $event2);
  39. $eventStack->flush();
  40. $this->assertCount(0, $eventStack);
  41. }
  42. }