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