Create config for the test suite

This commit is contained in:
Sergio Brighenti 2020-09-26 20:53:07 +02:00
parent 77bcc18807
commit 9de27e1278
7 changed files with 30 additions and 11 deletions

View file

@ -16,11 +16,11 @@ use Psr\Container\ContainerInterface as Container;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
if (!file_exists(BASE_DIR.'config.php') && is_dir(BASE_DIR.'install/')) {
if (!file_exists(CONFIG_FILE) && is_dir(BASE_DIR.'install/')) {
header('Location: ./install/');
exit();
} else {
if (!file_exists(BASE_DIR.'config.php') && !is_dir(BASE_DIR.'install/')) {
if (!file_exists(CONFIG_FILE) && !is_dir(BASE_DIR.'install/')) {
exit('Cannot find the config file.');
}
}
@ -48,7 +48,7 @@ $config = array_replace_recursive([
'base_domain' => null,
'user_domain' => null,
],
], require BASE_DIR.'config.php');
], require CONFIG_FILE);
$builder = new ContainerBuilder();

View file

@ -5,6 +5,7 @@ require __DIR__.'/vendor/autoload.php';
define('BASE_DIR', realpath(__DIR__).DIRECTORY_SEPARATOR);
define('PLATFORM_VERSION', json_decode(file_get_contents('composer.json'))->version);
define('CONFIG_FILE', BASE_DIR.'config.php');
$app = require_once __DIR__.'/bootstrap/app.php';
$app->run();

View file

@ -26,4 +26,8 @@
lowUpperBound="70"
highLowerBound="90"/>
</logging>
<php>
<server name="HTTP_HOST" value="localhost"/>
<server name="HTTPS" value="false"/>
</php>
</phpunit>

View file

@ -11,14 +11,10 @@ class Client extends AbstractBrowser
{
protected function doRequest($request)
{
define('BASE_DIR', realpath(__DIR__.'/../').DIRECTORY_SEPARATOR);
define('PLATFORM_VERSION', json_decode(file_get_contents(BASE_DIR.'composer.json'))->version);
/** @var \Slim\App $app */
$app = require_once BASE_DIR.'bootstrap/app.php';
$response = $app->handle(new ServerRequest($request->getMethod(), $request->getUri(), [], $request->getContent()));
return new Response($response->getBody()->getContents(), $response->getStatusCode(), $response->getHeaders());
}
}

View file

@ -2,8 +2,8 @@
namespace Tests;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\TestCase as BaseTestCase;
use Symfony\Component\BrowserKit\Response;
abstract class TestCase extends BaseTestCase
{
@ -12,9 +12,6 @@ abstract class TestCase extends BaseTestCase
protected function setUp()
{
$_SERVER['HTTP_HOST'] = 'http://localhost';
$_SERVER['HTTPS'] = false;
$this->client = new Client();
}

View file

@ -1,3 +1,7 @@
<?php
define('BASE_DIR', realpath(__DIR__.'/../').DIRECTORY_SEPARATOR);
define('PLATFORM_VERSION', json_decode(file_get_contents(BASE_DIR.'composer.json'))->version);
define('CONFIG_FILE', BASE_DIR.'tests/config_test.php');
ob_start();

17
tests/config_test.php Normal file
View file

@ -0,0 +1,17 @@
<?php
return [
'debug' => true,
// 'db' =>
// [
// 'connection' => 'sqlite',
// 'dsn' => ':memory:',
// 'username' => null,
// 'password' => null,
// ],
'storage' =>
[
'driver' => 'local',
'path' => 'storage/test',
],
];