Skip to content

Commit 3d3024b

Browse files
committed
keep the possiblity to override routeRequestHandler
1 parent 425b316 commit 3d3024b

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/Application.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,15 @@ final class Application implements RequestHandlerInterface
1717
{
1818
private PipeMiddleware $pipeMiddleware;
1919

20-
private RequestHandlerInterface $routeRequestHandler;
21-
22-
private EmitterInterface $emitter;
23-
2420
/**
2521
* @param array<MiddlewareInterface> $middlewares
2622
*/
2723
public function __construct(
2824
array $middlewares,
29-
?EmitterInterface $emitter = null
25+
private RequestHandlerInterface $routeRequestHandler = new RouteRequestHandler(),
26+
private EmitterInterface $emitter = new Emitter()
3027
) {
3128
$this->pipeMiddleware = new PipeMiddleware($middlewares);
32-
$this->routeRequestHandler = new RouteRequestHandler();
33-
$this->emitter = $emitter ?? new Emitter();
3429
}
3530

3631
public function __invoke(ServerRequestInterface $request): ResponseInterface

tests/Unit/ApplicationTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,15 @@ public function testEmit(): void
147147
/** @var MockObject|ResponseInterface $response */
148148
$response = $builder->create(ResponseInterface::class, []);
149149

150+
/** @var RequestHandlerInterface $routeRequestHandler */
151+
$routeRequestHandler = $builder->create(RequestHandlerInterface::class, []);
152+
150153
/** @var EmitterInterface $emitter */
151154
$emitter = $builder->create(EmitterInterface::class, [
152155
new WithReturn('emit', [$response], null),
153156
]);
154157

155-
$application = new Application([], $emitter);
158+
$application = new Application([], $routeRequestHandler, $emitter);
156159
$application->emit($response);
157160
}
158161
}

0 commit comments

Comments
 (0)