shlink/module/Rest/test/Middleware/EmptyResponseImplicitOptionsMiddlewareFactoryTest.php

46 lines
1.3 KiB
PHP
Raw Normal View History

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