コード例 #1
0
ファイル: bootstrap.php プロジェクト: CFLOVEYR/hook
$_SERVER['SERVER_NAME'] = 'localhost';
$_SERVER['SERVER_PORT'] = '80';
$_SERVER['SCRIPT_NAME'] = '/';
$db_driver = getenv('DB_DRIVER') ?: 'sqlite';
$db_config = (require __DIR__ . "/configs/{$db_driver}.php");
$app = (require __DIR__ . '/../src/Hook.php');
Hook\Http\Router::setInstance($app);
$app->config('database', $db_config);
$app->config('paths', require __DIR__ . '/../config/paths.php');
$app->config("view", new \Hook\View\View());
// remove previous database for a fresh test
if ($db_driver == 'sqlite') {
    @unlink($db_config['database']);
}
require __DIR__ . '/../src/bootstrap/connection.php';
Hook\Http\Router::setInstance($app);
//
// Ensure that tests will run against an valid fresh app
//
if (Hook\Model\AppKey::count() == 0) {
    $app->environment->offsetSet('PATH_INFO', '/apps');
    $app->environment->offsetSet('slim.request.form_hash', array('app' => array('name' => 'testing')));
    $app_controller = new Hook\Controllers\ApplicationController();
    $app_controller->create();
}
// Force application key for testing
Hook\Application\Context::setTablePrefix('');
Hook\Application\Context::setKey(Hook\Model\AppKey::with('app')->first());
$app->log->setWriter(new Hook\Logger\LogWriter(storage_dir() . '/logs.txt'));
class TestCase extends PHPUnit_Framework_TestCase
{
コード例 #2
0
ファイル: index.php プロジェクト: hyhyxu/hook
<?php

require __DIR__ . '/../vendor/autoload.php';
$app = (require __DIR__ . '/../src/bootstrap.php');
Hook\Http\Router::mount('/', 'Hook\\Application\\Routes')->run();