Skip to content
Browse files

Add tests to EventManager for propagation issue

- Tests that both trigger() and triggerUntil() will reset the
  stopPropagation flag as they start their work.
  • Loading branch information...
1 parent 2d6910a commit 9faca29830af432e8a02b5ea0bdd83150b015abc @weierophinney committed Mar 29, 2013
Showing with 33 additions and 0 deletions.
  1. +33 −0 tests/ZendTest/EventManager/EventManagerTest.php
View
33 tests/ZendTest/EventManager/EventManagerTest.php
@@ -657,4 +657,37 @@ public function testDoesNotCreateStaticInstanceIfNonePresent()
StaticEventManager::resetInstance();
$this->assertFalse($this->events->getSharedManager());
}
+
+ public function testTriggerSetsStopPropagationFlagToFalse()
+ {
+ $marker = (object) array('propagationIsStopped' => true);
+ $this->events->attach('foo', function ($e) use ($marker) {
+ $marker->propagationIsStopped = $e->propagationIsStopped();
+ });
+
+ $event = new Event();
+ $event->stopPropagation(true);
+ $this->events->trigger('foo', $event);
+
+ $this->assertFalse($marker->propagationIsStopped);
+ $this->assertFalse($event->propagationIsStopped());
+ }
+
+ public function testTriggerUntilSetsStopPropagationFlagToFalse()
+ {
+ $marker = (object) array('propagationIsStopped' => true);
+ $this->events->attach('foo', function ($e) use ($marker) {
+ $marker->propagationIsStopped = $e->propagationIsStopped();
+ });
+
+ $criteria = function ($r) {
+ return false;
+ };
+ $event = new Event();
+ $event->stopPropagation(true);
+ $this->events->triggerUntil('foo', $event, $criteria);
+
+ $this->assertFalse($marker->propagationIsStopped);
+ $this->assertFalse($event->propagationIsStopped());
+ }
}

0 comments on commit 9faca29

Please sign in to comment.
Something went wrong with that request. Please try again.