diff --git a/Slim/Factory/Psr17/SlimHttpPsr17Factory.php b/Slim/Factory/Psr17/SlimHttpPsr17Factory.php index 59691ee82..acc85482f 100644 --- a/Slim/Factory/Psr17/SlimHttpPsr17Factory.php +++ b/Slim/Factory/Psr17/SlimHttpPsr17Factory.php @@ -27,4 +27,15 @@ public static function createDecoratedResponseFactory( ): ResponseFactoryInterface { return new static::$responseFactoryClass($responseFactory, $streamFactory); } + + /** + * Set the response factory class the method `createDecoratedResponseFactory` + * should use. + * + * @param string $responseFactoryClass + */ + public static function setResponseFactory(string $responseFactoryClass): void + { + static::$responseFactoryClass = $responseFactoryClass; + } } diff --git a/tests/Factory/Psr17/SlimHttpPsr17FactoryTest.php b/tests/Factory/Psr17/SlimHttpPsr17FactoryTest.php new file mode 100644 index 000000000..b6a5ee38a --- /dev/null +++ b/tests/Factory/Psr17/SlimHttpPsr17FactoryTest.php @@ -0,0 +1,27 @@ +setAccessible(true); + + $this->assertEquals( + 'Slim\Http\Factory\AnotherDecoratedResponseFactory', + $responseFactoryClassProperty->getValue() + ); + } +}