@@ -238,7 +238,7 @@ function ($e) {}
238
238
$ this ->assertEquals (['content ' => 'ZendTest\Mvc\Controller\TestAsset\ForwardController::testAction ' ], $ result );
239
239
}
240
240
241
- public function testProblemListenersAreDetachedAndReattachedWhenPluginDispatchsRequestedController ()
241
+ public function testProblemListenersAreDetachedAndReattachedWhenPluginDispatchesRequestedController ()
242
242
{
243
243
$ services = $ this ->services ;
244
244
$ events = $ services ->get ('EventManager ' );
@@ -267,6 +267,35 @@ public function testProblemListenersAreDetachedAndReattachedWhenPluginDispatchsR
267
267
$ result = $ this ->plugin ->dispatch ('forward ' );
268
268
}
269
269
270
+ public function testInvokableProblemListenersAreDetachedAndReattachedWhenPluginDispatchesRequestedController ()
271
+ {
272
+ $ services = $ this ->services ;
273
+ $ events = $ services ->get ('EventManager ' );
274
+
275
+ $ myCallback = new ListenerStub ();
276
+ $ sharedEvents = $ this ->createMock (SharedEventManagerInterface::class);
277
+ $ sharedEvents ->expects ($ this ->once ())->method ('detach ' )->with ($ myCallback , 'Zend\Stdlib\DispatchableInterface ' );
278
+ $ sharedEvents
279
+ ->expects ($ this ->once ())
280
+ ->method ('attach ' )
281
+ ->with ('Zend\Stdlib\DispatchableInterface ' , MvcEvent::EVENT_DISPATCH , $ myCallback , -50 );
282
+ $ sharedEvents ->expects ($ this ->any ())->method ('getListeners ' )->will ($ this ->returnValue ([-50 => [$ myCallback ]]));
283
+ $ events = $ this ->createEventManager ($ sharedEvents );
284
+
285
+ $ application = $ this ->createMock (ApplicationInterface::class);
286
+ $ application ->expects ($ this ->any ())->method ('getEventManager ' )->will ($ this ->returnValue ($ events ));
287
+ $ event = $ this ->controller ->getEvent ();
288
+ $ event ->setApplication ($ application );
289
+
290
+ $ this ->plugin ->setListenersToDetach ([[
291
+ 'id ' => 'Zend\Stdlib\DispatchableInterface ' ,
292
+ 'event ' => MvcEvent::EVENT_DISPATCH ,
293
+ 'class ' => 'ZendTest\Mvc\Controller\Plugin\TestAsset\ListenerStub ' ,
294
+ ]]);
295
+
296
+ $ result = $ this ->plugin ->dispatch ('forward ' );
297
+ }
298
+
270
299
public function testDispatchWillSeedRouteMatchWithPassedParameters ()
271
300
{
272
301
$ result = $ this ->plugin ->dispatch ('forward ' , [
0 commit comments