shlink/module/Common/test/Factory/EmptyResponseImplicitOptionsMiddlewareFactoryTest.php

41 lines
1.2 KiB
PHP
Raw Normal View History

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