mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-22 15:13:59 -06:00
Fixed use of ImplicitOptionsMiddleware with its new signature
This commit is contained in:
parent
ea735fc0a0
commit
7b9ebbbb5f
@ -6,11 +6,18 @@ namespace Shlinkio\Shlink\Rest\Middleware;
|
||||
|
||||
use Laminas\Diactoros\Response\EmptyResponse;
|
||||
use Mezzio\Router\Middleware\ImplicitOptionsMiddleware;
|
||||
use Psr\Http\Message\ResponseFactoryInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class EmptyResponseImplicitOptionsMiddlewareFactory
|
||||
{
|
||||
public function __invoke(): ImplicitOptionsMiddleware
|
||||
{
|
||||
return new ImplicitOptionsMiddleware(fn () => new EmptyResponse());
|
||||
return new ImplicitOptionsMiddleware(new class implements ResponseFactoryInterface {
|
||||
public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
|
||||
{
|
||||
return new EmptyResponse();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ namespace ShlinkioTest\Shlink\Rest\Middleware;
|
||||
use Laminas\Diactoros\Response\EmptyResponse;
|
||||
use Mezzio\Router\Middleware\ImplicitOptionsMiddleware;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Http\Message\ResponseFactoryInterface;
|
||||
use ReflectionObject;
|
||||
use Shlinkio\Shlink\Rest\Middleware\EmptyResponseImplicitOptionsMiddlewareFactory;
|
||||
|
||||
@ -34,6 +35,10 @@ class EmptyResponseImplicitOptionsMiddlewareFactoryTest extends TestCase
|
||||
$ref = new ReflectionObject($instance);
|
||||
$prop = $ref->getProperty('responseFactory');
|
||||
$prop->setAccessible(true);
|
||||
self::assertInstanceOf(EmptyResponse::class, $prop->getValue($instance)());
|
||||
|
||||
/** @var ResponseFactoryInterface $value */
|
||||
$value = $prop->getValue($instance);
|
||||
|
||||
self::assertInstanceOf(EmptyResponse::class, $value->createResponse());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user