2024-05-22 02:33:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Slovocast\Tests;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase as PHPUnit_TestCase;
|
2024-05-30 02:56:19 +00:00
|
|
|
use Prophecy\Prophet;
|
2024-05-22 02:33:17 +00:00
|
|
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
|
|
|
use Slim\App;
|
|
|
|
use Slim\Psr7\Factory\StreamFactory;
|
|
|
|
use Slim\Psr7\Headers;
|
|
|
|
use Slim\Psr7\Request as SlimRequest;
|
|
|
|
use Slim\Psr7\Uri;
|
2024-05-23 00:39:33 +00:00
|
|
|
use Slovocast\Bootstrap;
|
2024-05-22 02:33:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the common test harness pattern lifted right out of the official
|
|
|
|
* SlimPHP Skeleton application.
|
|
|
|
*/
|
|
|
|
class TestCase extends PHPUnit_TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Generate an instance of the Application
|
|
|
|
*/
|
|
|
|
protected function getAppInstance(): App
|
|
|
|
{
|
2024-05-23 00:39:33 +00:00
|
|
|
return Bootstrap::init();
|
2024-05-22 02:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $method
|
|
|
|
* @param string path
|
|
|
|
* @param array $headers
|
|
|
|
* @param array $cookies
|
|
|
|
* @param array $serverParams
|
|
|
|
*/
|
|
|
|
protected function createRequest(
|
|
|
|
string $method,
|
|
|
|
string $path,
|
|
|
|
array $headers = [],
|
|
|
|
array $cookies = [],
|
|
|
|
array $serverParams = []
|
|
|
|
): Request {
|
|
|
|
$uri = new Uri('', '', 80, $path);
|
|
|
|
$handle = fopen('php://temp', 'w+');
|
|
|
|
$stream = (new StreamFactory())->createStreamFromResource($handle);
|
|
|
|
|
|
|
|
$h = new Headers();
|
|
|
|
foreach ($headers as $name => $value) {
|
|
|
|
$h->addHeader($name, $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new SlimRequest(
|
|
|
|
$method,
|
|
|
|
$uri,
|
|
|
|
$h,
|
|
|
|
$cookies,
|
|
|
|
$serverParams,
|
|
|
|
$stream
|
|
|
|
);
|
|
|
|
}
|
2024-05-30 02:56:19 +00:00
|
|
|
|
|
|
|
public function getProphet(): Prophet
|
|
|
|
{
|
|
|
|
return new Prophet();
|
|
|
|
}
|
2024-05-22 02:33:17 +00:00
|
|
|
}
|