Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Slim/Factory/Psr17/SlimHttpPsr17Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
27 changes: 27 additions & 0 deletions tests/Factory/Psr17/SlimHttpPsr17FactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Slim Framework (https://slimframework.com)
*
* @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
*/

namespace Slim\Tests\Factory\Psr17;

use ReflectionProperty;
use Slim\Factory\Psr17\SlimHttpPsr17Factory;
use Slim\Tests\TestCase;

class SlimHttpPsr17FactoryTest extends TestCase
{
public function testSetResponseFactory()
{
SlimHttpPsr17Factory::setResponseFactory('Slim\Http\Factory\AnotherDecoratedResponseFactory');
$responseFactoryClassProperty = new ReflectionProperty(SlimHttpPsr17Factory::class, 'responseFactoryClass');
$responseFactoryClassProperty->setAccessible(true);

$this->assertEquals(
'Slim\Http\Factory\AnotherDecoratedResponseFactory',
$responseFactoryClassProperty->getValue()
);
}
}