2017-04-13 10:52:17 +03:00
|
|
|
<?php
|
2017-10-12 11:13:20 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2017-04-13 10:52:17 +03:00
|
|
|
namespace ShlinkioTest\Shlink\Common\Factory;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Shlinkio\Shlink\Common\Factory\EmptyResponseImplicitOptionsMiddlewareFactory;
|
|
|
|
use Zend\Diactoros\Response\EmptyResponse;
|
2018-03-21 03:05:55 +03:00
|
|
|
use Zend\Expressive\Router\Middleware\ImplicitOptionsMiddleware;
|
2017-04-13 10:52:17 +03: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(), '');
|
|
|
|
|
|
|
|
$ref = new \ReflectionObject($instance);
|
|
|
|
$prop = $ref->getProperty('response');
|
|
|
|
$prop->setAccessible(true);
|
|
|
|
$this->assertInstanceOf(EmptyResponse::class, $prop->getValue($instance));
|
|
|
|
}
|
|
|
|
}
|