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

Commit 9282e63

Browse files
committed
Merge branch 'hotfix/10' into develop
Forward port #10
2 parents 2fb2ae6 + b501ed9 commit 9282e63

File tree

4 files changed

+97
-22
lines changed

4 files changed

+97
-22
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/benchmarks export-ignore
12
/test export-ignore
23
/vendor export-ignore
34
.coveralls.yml export-ignore

CHANGELOG.md

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,33 +82,49 @@ All notable changes to this project will be documented in this file, in reverse
8282

8383
- `FilterIterator::insert()` has been modified to raise an exception if the value provided is not a callable.
8484

85-
## 2.6.0 - TBD
85+
## 2.6.0 - 2015-09-29
8686

8787
### Added
8888

89-
- Nothing.
89+
- Added `Zend\EventManager\SharedEventsCapableInterface`. This interface will
90+
largely replace `Zend\EventManager\SharedEventManagerAwareInterface` in
91+
version 3, and the latter was updated to extend it.
92+
- Added `EventManager::triggerEvent(EventInterface $event)` as a
93+
forwards-compatibility feature.
94+
- Add `EventManager::triggerEventUntil(callable $callback, EventIterface $event)`
95+
as a forwards-compatibility feature.
96+
- Adds [Athletic](https://github.com/polyfractal/athletic) benchmarks to aid in
97+
gauging performanc impact of changes; these are a development change only.
9098

9199
### Deprecated
92100

93-
- Nothing.
94-
95-
### Removed
96-
97-
- Nothing.
98-
99-
### Fixed
100-
101-
- Nothing.
102-
103-
## 2.5.3 - TBD
104-
105-
### Added
106-
107-
- Nothing.
108-
109-
### Deprecated
110-
111-
- Nothing.
101+
- Marked `GlobalEventManager` as deprecated; this class will be removed in
102+
version 3.
103+
- Marked `StaticEventManager` as deprecated; this class will be removed in
104+
version 3.
105+
- Marked `SharedListenerAggregateInterface` as deprecated; this interface will
106+
be removed in version 3.
107+
- Marked `SharedEventAggregateAwareInterface` as deprecated; this interface will
108+
be removed in version 3.
109+
- Marked `SharedEventManagerAwareInterface` as deprecated; this interface will
110+
be removed in version 3.
111+
- Marked `EventManager::setSharedManager()` as deprecated; this method will be
112+
removed in version 3.
113+
- Marked `EventManager::unsetSharedManager()` as deprecated; this method will be
114+
removed in version 3.
115+
- Marked `EventManagerInterface::` and `EventManager::getEvents()` as
116+
deprecated; this method will be removed in version 3.
117+
- Marked `EventManagerInterface::` and `EventManager::getListeners()` as
118+
deprecated; this method will be removed in version 3.
119+
- Marked `EventManagerInterface::` and `Eventmanager::setEventClass()` as
120+
deprecated; this method is renamed to `setEventPrototype(EventInterface $event)`
121+
in version 3.
122+
- Marked `EventManagerInterface::` and `EventManager::attachAggregate()` as
123+
deprecated; this method will be removed in version 3.
124+
- Marked `EventManagerInterface::` and `EventManager::detachAggregate()` as
125+
deprecated; this method will be removed in version 3.
126+
- Marked `SharedEventManagerInterface::` and `SharedEventManager::getEvents()`
127+
as deprecated; this method will be removed in version 3.
112128

113129
### Removed
114130

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"prefer-stable": true,
1414
"extra": {
1515
"branch-alias": {
16-
"dev-master": "2.5-dev",
16+
"dev-master": "2.6-dev",
1717
"dev-develop": "3.0-dev"
1818
}
1919
},

test/EventManagerTest.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ public function testTriggerUntilShouldMarkResponseCollectionStoppedWhenCondition
182182
$this->events->attach('foo.bar', function () { return 'found'; }, 2);
183183
$this->events->attach('foo.bar', function () { return 'zero'; }, 1);
184184
// @codingStandardsIgnoreEnd
185+
185186
$responses = $this->events->triggerUntil(function ($result) {
186187
return ($result === 'found');
187188
}, 'foo.bar', $this);
@@ -200,6 +201,7 @@ public function testTriggerUntilShouldMarkResponseCollectionStoppedWhenCondition
200201
$this->events->attach('foo.bar', function () { return 'zero'; });
201202
$this->events->attach('foo.bar', function () { return 'found'; });
202203
// @codingStandardsIgnoreEnd
204+
203205
$responses = $this->events->triggerUntil(function ($result) {
204206
return ($result === 'found');
205207
}, 'foo.bar', $this);
@@ -216,6 +218,7 @@ public function testResponseCollectionIsNotStoppedWhenNoCallbackMatchedByTrigger
216218
$this->events->attach('foo.bar', function () { return 'found'; }, 2);
217219
$this->events->attach('foo.bar', function () { return 'zero'; }, 1);
218220
// @codingStandardsIgnoreEnd
221+
219222
$responses = $this->events->triggerUntil(function ($result) {
220223
return ($result === 'never found');
221224
}, 'foo.bar', $this);
@@ -232,6 +235,7 @@ public function testCallingEventsStopPropagationMethodHaltsEventEmission()
232235
$this->events->attach('foo.bar', function ($e) { return 'found'; }, 2);
233236
$this->events->attach('foo.bar', function ($e) { return 'zero'; }, 1);
234237
// @codingStandardsIgnoreEnd
238+
235239
$responses = $this->events->trigger('foo.bar');
236240
$this->assertInstanceOf('Zend\EventManager\ResponseCollection', $responses);
237241
$this->assertTrue($responses->stopped());
@@ -252,6 +256,7 @@ public function testCanAlterParametersWithinAEvent()
252256
$bar = $e->getParam('bar', '__NO_BAR__');
253257
return $foo . ":" . $bar;
254258
});
259+
255260
$responses = $this->events->trigger('foo.bar');
256261
$this->assertEquals('bar:baz', $responses->last());
257262
}
@@ -260,10 +265,12 @@ public function testParametersArePassedToEventByReference()
260265
{
261266
$params = [ 'foo' => 'bar', 'bar' => 'baz'];
262267
$args = $this->events->prepareArgs($params);
268+
263269
// @codingStandardsIgnoreStart
264270
$this->events->attach('foo.bar', function ($e) { $e->setParam('foo', 'FOO'); });
265271
$this->events->attach('foo.bar', function ($e) { $e->setParam('bar', 'BAR'); });
266272
// @codingStandardsIgnoreEnd
273+
267274
$responses = $this->events->trigger('foo.bar', $this, $args);
268275
$this->assertEquals('FOO', $args['foo']);
269276
$this->assertEquals('BAR', $args['bar']);
@@ -276,6 +283,7 @@ public function testCanPassObjectForEventParameters()
276283
$this->events->attach('foo.bar', function ($e) { $e->setParam('foo', 'FOO'); });
277284
$this->events->attach('foo.bar', function ($e) { $e->setParam('bar', 'BAR'); });
278285
// @codingStandardsIgnoreEnd
286+
279287
$responses = $this->events->trigger('foo.bar', $this, $params);
280288
$this->assertEquals('FOO', $params->foo);
281289
$this->assertEquals('BAR', $params->bar);
@@ -744,4 +752,54 @@ public function testTriggeringAnEventWithAnEmptyNameRaisesAnException($event, $m
744752
$this->events->$method($event);
745753
}
746754
}
755+
756+
public function testTriggerEventAcceptsEventInstanceAndTriggersListeners()
757+
{
758+
$event = $this->prophesize(EventInterface::class);
759+
$event->getName()->willReturn('test');
760+
$event->stopPropagation(false)->shouldBeCalled();
761+
$event->propagationIsStopped()->willReturn(false);
762+
763+
$triggered = false;
764+
$this->events->attach('test', function ($e) use ($event, &$triggered) {
765+
$this->assertSame($event->reveal(), $e);
766+
$triggered = true;
767+
});
768+
769+
$this->events->triggerEvent($event->reveal());
770+
$this->assertTrue($triggered, 'Listener for event was not triggered');
771+
}
772+
773+
public function testTriggerEventUntilAcceptsEventInstanceAndTriggersListenersUntilCallbackEvaluatesTrue()
774+
{
775+
$event = $this->prophesize(EventInterface::class);
776+
$event->getName()->willReturn('test');
777+
$event->stopPropagation(false)->shouldBeCalled();
778+
$event->propagationIsStopped()->willReturn(false);
779+
780+
$callback = function ($result) {
781+
return ($result === true);
782+
};
783+
784+
$triggeredOne = false;
785+
$this->events->attach('test', function ($e) use ($event, &$triggeredOne) {
786+
$this->assertSame($event->reveal(), $e);
787+
$triggeredOne = true;
788+
});
789+
790+
$triggeredTwo = false;
791+
$this->events->attach('test', function ($e) use ($event, &$triggeredTwo) {
792+
$this->assertSame($event->reveal(), $e);
793+
$triggeredTwo = true;
794+
return true;
795+
});
796+
797+
$this->events->attach('test', function ($e) {
798+
$this->fail('Third listener was triggered and should not have been');
799+
});
800+
801+
$this->events->triggerEventUntil($callback, $event->reveal());
802+
$this->assertTrue($triggeredOne, 'First Listener for event was not triggered');
803+
$this->assertTrue($triggeredTwo, 'First Listener for event was not triggered');
804+
}
747805
}

0 commit comments

Comments
 (0)