shlink/module/Common/test/Util/TestUtils.php
2018-03-26 18:49:28 +02:00

37 lines
934 B
PHP

<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Util;
use Prophecy\Argument;
use Prophecy\Prophet;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Server\RequestHandlerInterface as DelegateInterface;
use Zend\Diactoros\Response;
class TestUtils
{
private static $prophet;
public static function createDelegateMock(ResponseInterface $response = null, RequestInterface $request = null)
{
$argument = $request ?: Argument::any();
$delegate = static::getProphet()->prophesize(DelegateInterface::class);
$delegate->process($argument)->willReturn($response ?: new Response());
return $delegate;
}
/**
* @return Prophet
*/
private static function getProphet()
{
if (static::$prophet === null) {
static::$prophet = new Prophet();
}
return static::$prophet;
}
}