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

40 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2017-10-12 11:13:20 +03:00
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Rest\Middleware;
use PHPUnit\Framework\TestCase;
use ReflectionObject;
use Shlinkio\Shlink\Rest\Middleware\EmptyResponseImplicitOptionsMiddlewareFactory;
use Zend\Diactoros\Response\EmptyResponse;
use Zend\Expressive\Router\Middleware\ImplicitOptionsMiddleware;
class EmptyResponseImplicitOptionsMiddlewareFactoryTest extends TestCase
{
/** @var EmptyResponseImplicitOptionsMiddlewareFactory */
private $factory;
2019-02-16 12:53:45 +03:00
public function setUp(): void
{
$this->factory = new EmptyResponseImplicitOptionsMiddlewareFactory();
}
2019-02-17 22:28:34 +03:00
/** @test */
public function serviceIsCreated(): void
{
$instance = ($this->factory)();
$this->assertInstanceOf(ImplicitOptionsMiddleware::class, $instance);
}
2019-02-17 22:28:34 +03:00
/** @test */
public function responsePrototypeIsEmptyResponse(): void
{
$instance = ($this->factory)();
$ref = new ReflectionObject($instance);
2018-03-26 20:02:41 +03:00
$prop = $ref->getProperty('responseFactory');
$prop->setAccessible(true);
2018-03-26 20:02:41 +03:00
$this->assertInstanceOf(EmptyResponse::class, $prop->getValue($instance)());
}
}