2017-04-13 02:52:17 -05:00
|
|
|
<?php
|
2017-10-12 03:13:20 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2017-04-13 02:52:17 -05:00
|
|
|
namespace ShlinkioTest\Shlink\Common\Factory;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2018-10-28 02:24:06 -05:00
|
|
|
use ReflectionObject;
|
2017-04-13 02:52:17 -05:00
|
|
|
use Shlinkio\Shlink\Common\Factory\EmptyResponseImplicitOptionsMiddlewareFactory;
|
|
|
|
use Zend\Diactoros\Response\EmptyResponse;
|
2018-03-20 19:05:55 -05:00
|
|
|
use Zend\Expressive\Router\Middleware\ImplicitOptionsMiddleware;
|
2017-04-13 02:52:17 -05:00
|
|
|
use Zend\ServiceManager\ServiceManager;
|
|
|
|
|
|
|
|
class EmptyResponseImplicitOptionsMiddlewareFactoryTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var EmptyResponseImplicitOptionsMiddlewareFactory
|
|
|
|
*/
|
|
|
|
protected $factory;
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
$this->factory = new EmptyResponseImplicitOptionsMiddlewareFactory();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function serviceIsCreated()
|
|
|
|
{
|
|
|
|
$instance = $this->factory->__invoke(new ServiceManager(), '');
|
|
|
|
$this->assertInstanceOf(ImplicitOptionsMiddleware::class, $instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function responsePrototypeIsEmptyResponse()
|
|
|
|
{
|
|
|
|
$instance = $this->factory->__invoke(new ServiceManager(), '');
|
|
|
|
|
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);
|
2018-03-26 12:02:41 -05:00
|
|
|
$this->assertInstanceOf(EmptyResponse::class, $prop->getValue($instance)());
|
2017-04-13 02:52:17 -05:00
|
|
|
}
|
|
|
|
}
|