2021-05-14 18:52:00 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2021-05-14 18:57:35 +03:00
|
|
|
* PHP 7.2
|
2021-05-14 18:52:00 +03:00
|
|
|
*
|
2021-05-15 13:14:21 +03:00
|
|
|
* @category PockTestCase
|
|
|
|
* @package Pock\TestUtils
|
2021-05-14 18:52:00 +03:00
|
|
|
*/
|
|
|
|
|
2021-05-15 13:14:21 +03:00
|
|
|
namespace Pock\TestUtils;
|
2021-05-14 18:52:00 +03:00
|
|
|
|
|
|
|
use Nyholm\Psr7\Factory\Psr17Factory;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Pock\Enum\RequestMethod;
|
|
|
|
use Pock\Enum\RequestScheme;
|
|
|
|
use Psr\Http\Message\RequestInterface;
|
|
|
|
|
|
|
|
/**
|
2021-05-15 13:14:21 +03:00
|
|
|
* Class PockTestCase
|
2021-05-14 18:52:00 +03:00
|
|
|
*
|
2021-05-15 13:14:21 +03:00
|
|
|
* @category PockTestCase
|
|
|
|
* @package Pock\TestUtils
|
2021-05-14 18:52:00 +03:00
|
|
|
*/
|
2021-05-15 13:14:21 +03:00
|
|
|
abstract class PockTestCase extends TestCase
|
2021-05-14 18:52:00 +03:00
|
|
|
{
|
|
|
|
protected const TEST_METHOD = RequestMethod::GET;
|
|
|
|
protected const TEST_SCHEME = RequestScheme::HTTPS;
|
|
|
|
protected const TEST_HOST = 'example.com';
|
|
|
|
protected const TEST_URI = self::TEST_SCHEME . '://' . self::TEST_HOST . '/';
|
|
|
|
|
|
|
|
/** @var \Nyholm\Psr7\Factory\Psr17Factory */
|
2021-05-14 18:58:50 +03:00
|
|
|
protected static $psr17Factory;
|
2021-05-14 18:52:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Psr\Http\Message\RequestInterface
|
|
|
|
*/
|
|
|
|
protected static function getTestRequest(): RequestInterface
|
|
|
|
{
|
|
|
|
return static::getPsr17Factory()->createRequest(static::TEST_METHOD, static::TEST_URI);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Nyholm\Psr7\Factory\Psr17Factory
|
|
|
|
*/
|
|
|
|
protected static function getPsr17Factory(): Psr17Factory
|
|
|
|
{
|
|
|
|
if (null === static::$psr17Factory) {
|
|
|
|
static::$psr17Factory = new Psr17Factory();
|
|
|
|
}
|
|
|
|
|
|
|
|
return static::$psr17Factory;
|
|
|
|
}
|
|
|
|
}
|