php-censor/tests/bootstrap.php

70 lines
1.8 KiB
PHP
Raw Normal View History

<?php
/**
2016-05-19 17:25:43 +02:00
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2013, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
*/
2016-07-19 20:28:11 +02:00
use PHPCensor\Logging\LoggerConfig;
2016-05-19 17:25:43 +02:00
if (!defined('ROOT_DIR')) {
define('ROOT_DIR', dirname(__DIR__) . DIRECTORY_SEPARATOR);
}
2016-07-21 17:20:34 +02:00
if (!defined('SRC_DIR')) {
define('SRC_DIR', ROOT_DIR . 'src' . DIRECTORY_SEPARATOR . 'PHPCensor' . DIRECTORY_SEPARATOR);
2016-05-19 17:25:43 +02:00
}
2016-07-21 17:20:34 +02:00
if (!defined('PUBLIC_DIR')) {
define('PUBLIC_DIR', ROOT_DIR . 'public' . DIRECTORY_SEPARATOR);
2016-05-19 17:25:43 +02:00
}
2016-07-21 17:20:34 +02:00
if (!defined('APP_DIR')) {
define('APP_DIR', ROOT_DIR . 'app' . DIRECTORY_SEPARATOR);
2016-05-19 17:25:43 +02:00
}
2016-07-21 17:20:34 +02:00
if (!defined('BIN_DIR')) {
define('BIN_DIR', ROOT_DIR . 'bin' . DIRECTORY_SEPARATOR);
2016-05-19 17:25:43 +02:00
}
2016-07-21 17:20:34 +02:00
if (!defined('RUNTIME_DIR')) {
define('RUNTIME_DIR', ROOT_DIR . 'runtime' . DIRECTORY_SEPARATOR);
2016-05-19 17:25:43 +02:00
}
2014-12-08 16:09:57 +01:00
2016-05-19 17:25:43 +02:00
if (!defined('IS_WIN')) {
define('IS_WIN', ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false));
}
require_once(ROOT_DIR . 'vendor/autoload.php');
2016-07-19 20:28:11 +02:00
\PHPCensor\ErrorHandler::register();
2016-05-19 17:25:43 +02:00
2016-07-21 17:20:34 +02:00
if (defined('IS_CONSOLE') && IS_CONSOLE) {
$loggerConfig = LoggerConfig::newFromFile(APP_DIR . "loggerconfig.php");
2014-12-08 16:09:57 +01:00
}
2014-12-25 22:20:11 +01:00
// Load configuration if present:
2016-05-19 17:25:43 +02:00
$conf = [];
2016-07-19 20:28:11 +02:00
$conf['b8']['app']['namespace'] = 'PHPCensor';
2014-12-25 22:20:11 +01:00
$conf['b8']['app']['default_controller'] = 'Home';
2016-07-21 17:20:34 +02:00
$conf['b8']['view']['path'] = SRC_DIR . 'View' . DIRECTORY_SEPARATOR;
2014-12-25 22:20:11 +01:00
$config = new b8\Config($conf);
2016-07-21 17:20:34 +02:00
$configFile = APP_DIR . 'config.yml';
2014-12-08 16:09:57 +01:00
if (file_exists($configFile)) {
$config->loadYaml($configFile);
}
2016-07-21 17:20:34 +02:00
if (!defined('APP_URL') && !empty($config)) {
2016-07-21 19:02:11 +02:00
define('APP_URL', $config->get('php-censor.url', '') . '/');
2016-05-19 17:25:43 +02:00
}
2016-07-21 17:20:34 +02:00
if (!defined('IS_CONSOLE')) {
define('IS_CONSOLE', false);
2016-05-19 17:25:43 +02:00
}
2014-12-08 16:04:44 +01:00
2016-07-19 20:28:11 +02:00
\PHPCensor\Helper\Lang::init($config);