Skip to content

Commit

Permalink
Create config for the test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
sergix44 committed Sep 26, 2020
1 parent 77bcc18 commit 9de27e1
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
6 changes: 3 additions & 3 deletions bootstrap/app.php
Expand Up @@ -16,11 +16,11 @@
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.');
}
}
Expand Down Expand Up @@ -48,7 +48,7 @@
'base_domain' => null,
'user_domain' => null,
],
], require BASE_DIR.'config.php');
], require CONFIG_FILE);

$builder = new ContainerBuilder();

Expand Down
1 change: 1 addition & 0 deletions index.php
Expand Up @@ -5,6 +5,7 @@

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();
4 changes: 4 additions & 0 deletions phpunit.xml
Expand Up @@ -26,4 +26,8 @@
lowUpperBound="70"
highLowerBound="90"/>
</logging>
<php>
<server name="HTTP_HOST" value="localhost"/>
<server name="HTTPS" value="false"/>
</php>
</phpunit>
4 changes: 0 additions & 4 deletions tests/Client.php
Expand Up @@ -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());
}
}
5 changes: 1 addition & 4 deletions tests/TestCase.php
Expand Up @@ -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
{
Expand All @@ -12,9 +12,6 @@ abstract class TestCase extends BaseTestCase

protected function setUp()
{
$_SERVER['HTTP_HOST'] = 'http://localhost';
$_SERVER['HTTPS'] = false;

$this->client = new Client();
}

Expand Down
4 changes: 4 additions & 0 deletions tests/bootstrap.php
@@ -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 changes: 17 additions & 0 deletions tests/config_test.php
@@ -0,0 +1,17 @@
<?php

return [
'debug' => true,
// 'db' =>
// [
// 'connection' => 'sqlite',
// 'dsn' => ':memory:',
// 'username' => null,
// 'password' => null,
// ],
'storage' =>
[
'driver' => 'local',
'path' => 'storage/test',
],
];

0 comments on commit 9de27e1

Please sign in to comment.