diff --git a/config/autoload/dependencies.global.php b/config/autoload/dependencies.global.php index e2b88ba8..83a893dc 100644 --- a/config/autoload/dependencies.global.php +++ b/config/autoload/dependencies.global.php @@ -1,6 +1,8 @@ Twig\TwigEnvironmentFactory::class, Router\RouterInterface::class => Router\FastRouteRouterFactory::class, ErrorHandler::class => Container\ErrorHandlerFactory::class, + Middleware\ImplicitOptionsMiddleware::class => EmptyResponseImplicitOptionsMiddlewareFactory::class, ], ], diff --git a/module/Common/src/Factory/EmptyResponseImplicitOptionsMiddlewareFactory.php b/module/Common/src/Factory/EmptyResponseImplicitOptionsMiddlewareFactory.php new file mode 100644 index 00000000..1551d8cd --- /dev/null +++ b/module/Common/src/Factory/EmptyResponseImplicitOptionsMiddlewareFactory.php @@ -0,0 +1,30 @@ +factory = new EmptyResponseImplicitOptionsMiddlewareFactory(); + } + + /** + * @test + */ + public function serviceIsCreated() + { + $instance = $this->factory->__invoke(new ServiceManager(), ''); + $this->assertInstanceOf(ImplicitOptionsMiddleware::class, $instance); + } + + /** + * @test + */ + public function responsePrototypeIsEmptyResponse() + { + $instance = $this->factory->__invoke(new ServiceManager(), ''); + + $ref = new \ReflectionObject($instance); + $prop = $ref->getProperty('response'); + $prop->setAccessible(true); + $this->assertInstanceOf(EmptyResponse::class, $prop->getValue($instance)); + } +}