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;
|
2018-10-28 10:24:06 +03:00
|
|
|
use ReflectionObject;
|
2017-04-13 10:52:17 +03:00
|
|
|
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
|
|
|
|
{
|
2018-11-20 21:30:27 +03:00
|
|
|
/** @var EmptyResponseImplicitOptionsMiddlewareFactory */
|
2018-11-20 21:37:22 +03:00
|
|
|
private $factory;
|
2017-04-13 10:52:17 +03:00
|
|
|
|
2019-02-16 12:53:45 +03:00
|
|
|
public function setUp(): void
|
2017-04-13 10:52:17 +03:00
|
|
|
{
|
|
|
|
$this->factory = new EmptyResponseImplicitOptionsMiddlewareFactory();
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:28:34 +03:00
|
|
|
/** @test */
|
2017-04-13 10:52:17 +03:00
|
|
|
public function serviceIsCreated()
|
|
|
|
{
|
|
|
|
$instance = $this->factory->__invoke(new ServiceManager(), '');
|
|
|
|
$this->assertInstanceOf(ImplicitOptionsMiddleware::class, $instance);
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:28:34 +03:00
|
|
|
/** @test */
|
2017-04-13 10:52:17 +03:00
|
|
|
public function responsePrototypeIsEmptyResponse()
|
|
|
|
{
|
|
|
|
$instance = $this->factory->__invoke(new ServiceManager(), '');
|
|
|
|
|
2018-10-28 10:24:06 +03:00
|
|
|
$ref = new ReflectionObject($instance);
|
2018-03-26 20:02:41 +03:00
|
|
|
$prop = $ref->getProperty('responseFactory');
|
2017-04-13 10:52:17 +03:00
|
|
|
$prop->setAccessible(true);
|
2018-03-26 20:02:41 +03:00
|
|
|
$this->assertInstanceOf(EmptyResponse::class, $prop->getValue($instance)());
|
2017-04-13 10:52:17 +03:00
|
|
|
}
|
|
|
|
}
|