2017-04-13 09:52:17 +02:00
|
|
|
<?php
|
2019-10-05 17:26:10 +02:00
|
|
|
|
2017-10-12 10:13:20 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-08-11 13:20:18 +02:00
|
|
|
namespace ShlinkioTest\Shlink\Rest\Middleware;
|
2017-04-13 09:52:17 +02:00
|
|
|
|
2020-01-01 21:11:53 +01:00
|
|
|
use Laminas\Diactoros\Response\EmptyResponse;
|
|
|
|
use Mezzio\Router\Middleware\ImplicitOptionsMiddleware;
|
2017-04-13 09:52:17 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2021-07-30 18:05:03 +02:00
|
|
|
use Psr\Http\Message\ResponseFactoryInterface;
|
2018-10-28 08:24:06 +01:00
|
|
|
use ReflectionObject;
|
2019-08-11 13:20:18 +02:00
|
|
|
use Shlinkio\Shlink\Rest\Middleware\EmptyResponseImplicitOptionsMiddlewareFactory;
|
2017-04-13 09:52:17 +02:00
|
|
|
|
|
|
|
class EmptyResponseImplicitOptionsMiddlewareFactoryTest extends TestCase
|
|
|
|
{
|
2019-12-29 22:48:40 +01:00
|
|
|
private EmptyResponseImplicitOptionsMiddlewareFactory $factory;
|
2017-04-13 09:52:17 +02:00
|
|
|
|
2022-09-11 12:02:49 +02:00
|
|
|
protected function setUp(): void
|
2017-04-13 09:52:17 +02:00
|
|
|
{
|
|
|
|
$this->factory = new EmptyResponseImplicitOptionsMiddlewareFactory();
|
|
|
|
}
|
|
|
|
|
2019-02-17 20:28:34 +01:00
|
|
|
/** @test */
|
2019-08-10 23:58:21 +02:00
|
|
|
public function serviceIsCreated(): void
|
2017-04-13 09:52:17 +02:00
|
|
|
{
|
2019-08-10 23:58:21 +02:00
|
|
|
$instance = ($this->factory)();
|
2020-10-04 00:35:14 +02:00
|
|
|
self::assertInstanceOf(ImplicitOptionsMiddleware::class, $instance);
|
2017-04-13 09:52:17 +02:00
|
|
|
}
|
|
|
|
|
2019-02-17 20:28:34 +01:00
|
|
|
/** @test */
|
2019-08-10 23:58:21 +02:00
|
|
|
public function responsePrototypeIsEmptyResponse(): void
|
2017-04-13 09:52:17 +02:00
|
|
|
{
|
2019-08-10 23:58:21 +02:00
|
|
|
$instance = ($this->factory)();
|
2017-04-13 09:52:17 +02:00
|
|
|
|
2018-10-28 08:24:06 +01:00
|
|
|
$ref = new ReflectionObject($instance);
|
2018-03-26 19:02:41 +02:00
|
|
|
$prop = $ref->getProperty('responseFactory');
|
2017-04-13 09:52:17 +02:00
|
|
|
$prop->setAccessible(true);
|
2021-07-30 18:05:03 +02:00
|
|
|
|
|
|
|
/** @var ResponseFactoryInterface $value */
|
|
|
|
$value = $prop->getValue($instance);
|
|
|
|
|
|
|
|
self::assertInstanceOf(EmptyResponse::class, $value->createResponse());
|
2017-04-13 09:52:17 +02:00
|
|
|
}
|
|
|
|
}
|