2525use Zend \Expressive \MiddlewareFactory ;
2626use Zend \Expressive \Router \Middleware \DispatchMiddleware ;
2727use Zend \Expressive \Router \Middleware \MethodNotAllowedMiddleware ;
28- use Zend \Expressive \Router \Middleware \PathBasedRoutingMiddleware ;
28+ use Zend \Expressive \Router \Middleware \RouteMiddleware ;
2929use Zend \Expressive \Router \Route ;
30+ use Zend \Expressive \Router \RouteCollector ;
3031use Zend \Expressive \Router \RouterInterface ;
3132use Zend \HttpHandlerRunner \RequestHandlerRunner ;
3233use Zend \Stratigility \MiddlewarePipe ;
@@ -46,7 +47,10 @@ class ApplicationConfigInjectionDelegatorTest extends TestCase
4647 /** @var MethodNotAllowedMiddleware|ObjectProphecy */
4748 private $ methodNotAllowedMiddleware ;
4849
49- /** @var PathBasedRoutingMiddleware */
50+ /** @var RouteCollector */
51+ private $ routeCollector ;
52+
53+ /** @var RouteMiddleware */
5054 private $ routeMiddleware ;
5155
5256 /** @var RouterInterface|ObjectProphecy */
@@ -56,10 +60,8 @@ public function setUp()
5660 {
5761 $ this ->container = $ this ->mockContainerInterface ();
5862 $ this ->router = $ this ->prophesize (RouterInterface::class);
59- $ this ->routeMiddleware = new PathBasedRoutingMiddleware (
60- $ this ->router ->reveal (),
61- new Response ()
62- );
63+ $ this ->routeCollector = new RouteCollector ($ this ->router ->reveal ());
64+ $ this ->routeMiddleware = new RouteMiddleware ($ this ->router ->reveal ());
6365 $ this ->dispatchMiddleware = $ this ->prophesize (DispatchMiddleware::class)->reveal ();
6466 $ this ->methodNotAllowedMiddleware = $ this ->prophesize (MethodNotAllowedMiddleware::class)->reveal ();
6567 }
@@ -73,7 +75,7 @@ public function createApplication()
7375 return new Application (
7476 $ factory ,
7577 $ pipeline ,
76- $ this ->routeMiddleware ,
78+ $ this ->routeCollector ,
7779 $ runner
7880 );
7981 }
@@ -139,63 +141,6 @@ public static function assertPipelineContainsInstanceOf($class, $pipeline, $mess
139141 Assert::assertThat ($ found , Assert::isTrue (), $ message );
140142 }
141143
142- public static function assertRouteMiddleware (MiddlewareInterface $ middleware )
143- {
144- if ($ middleware instanceof PathBasedRoutingMiddleware) {
145- Assert::assertInstanceOf (PathBasedRoutingMiddleware::class, $ middleware );
146- return ;
147- }
148-
149- if (! $ middleware instanceof Middleware \LazyLoadingMiddleware) {
150- Assert::fail ('Middleware is not an instance of PathBasedRoutingMiddleware ' );
151- }
152-
153- Assert::assertAttributeSame (
154- PathBasedRoutingMiddleware::class,
155- 'middlewareName ' ,
156- $ middleware ,
157- 'Middleware is not an instance of PathBasedRoutingMiddleware '
158- );
159- }
160-
161- public static function assertDispatchMiddleware (MiddlewareInterface $ middleware )
162- {
163- if ($ middleware instanceof DispatchMiddleware) {
164- Assert::assertInstanceOf (DispatchMiddleware::class, $ middleware );
165- return ;
166- }
167-
168- if (! $ middleware instanceof Middleware \LazyLoadingMiddleware) {
169- Assert::fail ('Middleware is not an instance of DispatchMiddleware ' );
170- }
171-
172- Assert::assertAttributeSame (
173- DispatchMiddleware::class,
174- 'middlewareName ' ,
175- $ middleware ,
176- 'Middleware is not an instance of DispatchMiddleware '
177- );
178- }
179-
180- public static function assertMethodNotAllowedMiddleware (MiddlewareInterface $ middleware )
181- {
182- if ($ middleware instanceof MethodNotAllowedMiddleware) {
183- Assert::assertInstanceOf (MethodNotAllowedMiddleware::class, $ middleware );
184- return ;
185- }
186-
187- if (! $ middleware instanceof Middleware \LazyLoadingMiddleware) {
188- Assert::fail ('Middleware is not an instance of MethodNotAllowedMiddleware ' );
189- }
190-
191- Assert::assertAttributeSame (
192- MethodNotAllowedMiddleware::class,
193- 'middlewareName ' ,
194- $ middleware ,
195- 'Middleware is not an instance of MethodNotAllowedMiddleware '
196- );
197- }
198-
199144 public function callableMiddlewares ()
200145 {
201146 return [
@@ -416,16 +361,6 @@ public function testInjectRoutesFromConfigWillSkipSpecsThatOmitPath()
416361 ],
417362 ];
418363 $ this ->container ->has ('config ' )->willReturn (false );
419- $ this ->injectServiceInContainer (
420- $ this ->container ,
421- PathBasedRoutingMiddleware::class,
422- $ this ->routeMiddleware
423- );
424- $ this ->injectServiceInContainer (
425- $ this ->container ,
426- DispatchMiddleware::class,
427- $ this ->dispatchMiddleware
428- );
429364
430365 $ app = $ this ->createApplication ();
431366
@@ -447,16 +382,6 @@ public function testInjectRoutesFromConfigWillSkipSpecsThatOmitMiddleware()
447382 ],
448383 ];
449384 $ this ->container ->has ('config ' )->willReturn (false );
450- $ this ->injectServiceInContainer (
451- $ this ->container ,
452- PathBasedRoutingMiddleware::class,
453- $ this ->routeMiddleware
454- );
455- $ this ->injectServiceInContainer (
456- $ this ->container ,
457- DispatchMiddleware::class,
458- $ this ->dispatchMiddleware
459- );
460385
461386 $ app = $ this ->createApplication ();
462387
0 commit comments