Пример #1
0
 public static function init_session()
 {
     Session::gc();
     $session_data = Session::start();
     AppContext::set_session($session_data);
     AppContext::init_current_user();
     $current_user = AppContext::get_current_user();
     $user_accounts_config = UserAccountsConfig::load();
     $user_theme = ThemesManager::get_theme($current_user->get_theme());
     $default_theme = $user_accounts_config->get_default_theme();
     if ($user_theme === null || (!$user_theme->check_auth() || !$user_theme->is_activated()) && $user_theme->get_id() !== $default_theme) {
         AppContext::get_current_user()->update_theme($default_theme);
     }
     $user_lang = LangsManager::get_lang($current_user->get_locale());
     $default_lang = $user_accounts_config->get_default_lang();
     if ($user_lang === null || (!$user_lang->check_auth() || !$user_lang->is_activated()) && $user_lang->get_id() !== $default_lang) {
         AppContext::get_current_user()->update_lang($default_lang);
     }
 }
Пример #2
0
<?php

define('PATH_TO_ROOT', '..');
define('DEBUG', TRUE);
require_once PATH_TO_ROOT . '/kernel/framework/core/environment/Environment.class.php';
Environment::load_imports();
Environment::load_static_constants();
AppContext::set_request(new HTTPRequestCustom());
Session::gc();
$session_data = Session::start();
AppContext::set_session($session_data);
AppContext::init_current_user();
require_once PATH_TO_ROOT . '/test/PHPUnit/Framework.php';
if (isset($argv)) {
    array_shift($argv);
    $_REQUEST['params'] = implode(' ', $argv);
    $_REQUEST['is_html'] = false;
}
if (!empty($_REQUEST['params'])) {
    // Fake command line environment
    $argv = $_REQUEST['params'];
    $_SERVER['argv'] = explode(' ', '--configuration ./phpunit.cfg.xml ' . $argv);
} else {
    $_SERVER['argv'] = array();
}
$is_html = isset($_REQUEST['is_html']) && $_REQUEST['is_html'] == true;
if (!$is_html) {
    echo '<pre>';
}
//Debug::dump($_SERVER['argv']);
require_once PATH_TO_ROOT . '/test/phpunit.php';