for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Flatdown\Tests;
use Flatdown\Application;
use Middlewares\Utils\Factory\ServerRequestFactory;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
abstract class BaseTestCase extends TestCase
{
/**
* @return Application
*/
protected function createApp()
$app = include __DIR__ . '/../bootstrap/app.php';
$this->assertInstanceOf(Application::class, $app);
return $app;
}
* @param string $method
* @param string $uri
* @return ServerRequestInterface
protected function createRequest($method, $uri)
if (!preg_match('/^http/', $uri)) {
$uri = 'http://localhost/' . ltrim($uri, '/');
$request = (new ServerRequestFactory())->createServerRequest($method, $uri);
$this->assertInstanceOf(ServerRequestInterface::class, $request);
return $request;
* @param ServerRequestInterface $request
* @return ResponseInterface
protected function call(ServerRequestInterface $request)
$app = $this->createApp();
$response = $app->dispatch($request);
$this->assertInstanceOf(ResponseInterface::class, $response);
return $response;