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

Commit 533a489

Browse files
committed
Verifying that the MiddlewareListener triggers no error events on skipped dispatch
1 parent 0ce89d1 commit 533a489

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/MiddlewareListenerTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ public function testWillNotDispatchWhenAnMvcEventResultIsAlreadySet($alreadySetR
521521
$routeMatch = new RouteMatch(['middleware' => $middlewareName]);
522522
/* @var $application Application|\PHPUnit_Framework_MockObject_MockObject */
523523
$application = $this->createMock(Application::class);
524+
$eventManager = new EventManager();
524525
$middleware = $this->getMockBuilder(\stdClass::class)->setMethods(['__invoke'])->getMock();
525526
$serviceManager = new ServiceManager([
526527
'factories' => [
@@ -534,7 +535,7 @@ public function testWillNotDispatchWhenAnMvcEventResultIsAlreadySet($alreadySetR
534535
]);
535536

536537
$application->expects(self::any())->method('getRequest')->willReturn(new Request());
537-
$application->expects(self::any())->method('getEventManager')->willReturn(new EventManager());
538+
$application->expects(self::any())->method('getEventManager')->willReturn($eventManager);
538539
$application->expects(self::any())->method('getServiceManager')->willReturn($serviceManager);
539540
$application->expects(self::any())->method('getResponse')->willReturn(new Response());
540541
$middleware->expects(self::never())->method('__invoke');
@@ -549,6 +550,10 @@ public function testWillNotDispatchWhenAnMvcEventResultIsAlreadySet($alreadySetR
549550

550551
$listener = new MiddlewareListener();
551552

553+
$eventManager->attach(MvcEvent::EVENT_DISPATCH_ERROR, function () {
554+
self::fail('No dispatch failures should be raised - dispatch should be skipped');
555+
});
556+
552557
$listener->onDispatch($event);
553558

554559
self::assertSame($alreadySetResult, $event->getResult(), 'The event result was not replaced');

0 commit comments

Comments
 (0)