Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 3bcbcd3

Browse files
author
Witold Wasiczko
committed
Fix
1 parent 44ba66b commit 3bcbcd3

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/EventManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,6 @@ public function trigger($event, $target = null, $argv = [], $callback = null)
208208
throw new Exception\InvalidCallbackException('Invalid callback provided');
209209
}
210210

211-
// Initial value of stop propagation flag should be false
212-
$e->stopPropagation(false);
213-
214211
return $this->triggerListeners($event, $e, $callback);
215212
}
216213

@@ -461,6 +458,9 @@ public function prepareArgs(array $args)
461458
*/
462459
protected function triggerListeners($event, EventInterface $e, $callback = null)
463460
{
461+
// Initial value of stop propagation flag should be false
462+
$e->stopPropagation(false);
463+
464464
$responses = new ResponseCollection;
465465
$listeners = $this->getListeners($event);
466466

test/EventManagerTest.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,25 @@
1010
namespace ZendTest\EventManager;
1111

1212
use ArrayIterator;
13+
use ReflectionClass;
1314
use stdClass;
1415
use Zend\EventManager\Event;
1516
use Zend\EventManager\EventInterface;
1617
use Zend\EventManager\EventManager;
1718
use Zend\EventManager\SharedEventManager;
1819
use Zend\EventManager\StaticEventManager;
19-
use ReflectionClass;
20-
use Zend\Stdlib\CallBackHandler;
20+
use Zend\Stdlib\CallbackHandler;
2121

2222
/**
2323
* @group Zend_EventManager
2424
*/
2525
class EventManagerTest extends \PHPUnit_Framework_TestCase
2626
{
27+
/**
28+
* @var EventManager
29+
*/
30+
protected $events;
31+
2732
public function setUp()
2833
{
2934
StaticEventManager::resetInstance();
@@ -682,7 +687,7 @@ public function testTriggerEventSetsStopPropagationFlagToFalse()
682687
$marker->propagationIsStopped = $e->propagationIsStopped();
683688
});
684689

685-
$event = new Event();
690+
$event = new Event('foo');
686691
$event->stopPropagation(true);
687692
$this->events->triggerEvent($event);
688693

@@ -718,7 +723,7 @@ public function testTriggerEventUntilSetsStopPropagationFlagToFalse()
718723
$criteria = function ($r) {
719724
return false;
720725
};
721-
$event = new Event();
726+
$event = new Event('foo');
722727
$event->stopPropagation(true);
723728
$this->events->triggerEventUntil($criteria, $event);
724729

@@ -836,8 +841,10 @@ public function testResponseCollectionLastReturnsNull()
836841
public function testTriggerEventAcceptsEventInstanceAndTriggersListeners()
837842
{
838843
$event = $this->prophesize(EventInterface::class);
844+
$event->stopPropagation(false)->will(function () {
845+
$this->propagationIsStopped()->willReturn(false);
846+
});
839847
$event->getName()->willReturn('test');
840-
$event->propagationIsStopped()->willReturn(false);
841848

842849
$triggered = false;
843850
$this->events->attach('test', function ($e) use ($event, &$triggered) {
@@ -852,8 +859,10 @@ public function testTriggerEventAcceptsEventInstanceAndTriggersListeners()
852859
public function testTriggerEventUntilAcceptsEventInstanceAndTriggersListenersUntilCallbackEvaluatesTrue()
853860
{
854861
$event = $this->prophesize(EventInterface::class);
862+
$event->stopPropagation(false)->will(function () {
863+
$this->propagationIsStopped()->willReturn(false);
864+
});
855865
$event->getName()->willReturn('test');
856-
$event->propagationIsStopped()->willReturn(false);
857866

858867
$callback = function ($result) {
859868
return ($result === true);

0 commit comments

Comments
 (0)