Skip to content

Commit 87826af

Browse files
committed
remove unneded SendResponseListener detach
1 parent 98741f9 commit 87826af

File tree

2 files changed

+0
-39
lines changed

2 files changed

+0
-39
lines changed

spec/Listener/ForceHttpsSpec.php

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Zend\Http\PhpEnvironment\Response;
1313
use Zend\Mvc\Application;
1414
use Zend\Mvc\MvcEvent;
15-
use Zend\Mvc\SendResponseListener;
1615
use Zend\Router\RouteMatch;
1716
use Zend\Uri\Uri;
1817

@@ -76,8 +75,6 @@
7675

7776
beforeEach(function () {
7877
$this->mvcEvent = Double::instance(['extends' => MvcEvent::class, 'methods' => '__construct']);
79-
$this->application = Double::instance(['extends' => Application::class, 'methods' => '__construct']);
80-
$this->sendResponseListener = Double::instance(['extends' => SendResponseListener::class, 'methods' => '__construct']);
8178
$this->response = Double::instance(['extends' => Response::class]);
8279
$this->request = Double::instance(['extends' => Request::class]);
8380
$this->uri = Double::instance(['extends' => Uri::class]);
@@ -157,12 +154,6 @@
157154
allow($this->response)->toReceive('getHeaders', 'addHeaderLine')->with('Location', 'https://example.com/about');
158155
allow($this->response)->toReceive('send');
159156

160-
allow($this->mvcEvent)->toReceive('getApplication')->andReturn($this->application);
161-
allow($this->application)->toReceive('getEventManager')->andReturn($this->eventManager);
162-
allow($this->application)->toReceive('getServiceManager', 'get')
163-
->with('SendResponseListener')
164-
->andReturn($this->sendResponseListener);
165-
166157
$closure = function () use ($listener) {
167158
$listener->forceHttpsScheme($this->mvcEvent);
168159
};
@@ -198,12 +189,6 @@
198189
allow($this->response)->toReceive('getHeaders', 'addHeaderLine')->with('Location', 'https://example.com/about');
199190
allow($this->response)->toReceive('send');
200191

201-
allow($this->mvcEvent)->toReceive('getApplication')->andReturn($this->application);
202-
allow($this->application)->toReceive('getEventManager')->andReturn($this->eventManager);
203-
allow($this->application)->toReceive('getServiceManager', 'get')
204-
->with('SendResponseListener')
205-
->andReturn($this->sendResponseListener);
206-
207192
$closure = function () use ($listener) {
208193
$listener->forceHttpsScheme($this->mvcEvent);
209194
};
@@ -237,12 +222,6 @@
237222
allow($this->response)->toReceive('getHeaders', 'addHeaderLine')->with('Location', 'https://example.com/about');
238223
allow($this->response)->toReceive('send');
239224

240-
allow($this->mvcEvent)->toReceive('getApplication')->andReturn($this->application);
241-
allow($this->application)->toReceive('getEventManager')->andReturn($this->eventManager);
242-
allow($this->application)->toReceive('getServiceManager', 'get')
243-
->with('SendResponseListener')
244-
->andReturn($this->sendResponseListener);
245-
246225
$closure = function () use ($listener) {
247226
$listener->forceHttpsScheme($this->mvcEvent);
248227
};
@@ -278,12 +257,6 @@
278257
allow($this->response)->toReceive('getHeaders', 'addHeaderLine')->with('Location', 'https://example.com/about');
279258
allow($this->response)->toReceive('send');
280259

281-
allow($this->mvcEvent)->toReceive('getApplication')->andReturn($this->application);
282-
allow($this->application)->toReceive('getEventManager')->andReturn($this->eventManager);
283-
allow($this->application)->toReceive('getServiceManager', 'get')
284-
->with('SendResponseListener')
285-
->andReturn($this->sendResponseListener);
286-
287260
$closure = function () use ($listener) {
288261
$listener->forceHttpsScheme($this->mvcEvent);
289262
};
@@ -321,12 +294,6 @@
321294
->with('Location', 'https://example.com/about')
322295
->andReturn($this->response);
323296

324-
allow($this->mvcEvent)->toReceive('getApplication')->andReturn($this->application);
325-
allow($this->application)->toReceive('getEventManager')->andReturn($this->eventManager);
326-
allow($this->application)->toReceive('getServiceManager', 'get')
327-
->with('SendResponseListener')
328-
->andReturn($this->sendResponseListener);
329-
330297
allow($this->response)->toReceive('setStatusCode')->with(308)->andReturn($this->response);
331298
allow($this->response)->toReceive('send');
332299

src/Listener/ForceHttps.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@ public function forceHttpsScheme(MvcEvent $e) : void
8888
$httpsRequestUri = $this->getFinalhttpsRequestUri($uriString);
8989
}
9090

91-
$application = $e->getApplication();
92-
$events = $application->getEventManager();
93-
$serviceManager = $application->getServiceManager();
94-
$serviceManager->get('SendResponseListener')
95-
->detach($events);
96-
9791
// 308 keeps headers, request method, and request body
9892
$response->setStatusCode(308);
9993
$response->getHeaders()

0 commit comments

Comments
 (0)