public function testGetWithNoLanguageSet()
 {
     PhalApi_Translator_Mock::setLanguageNameSimple(null);
     $rs = T('test');
     PhalApi_Translator::setLanguage('zh_cn');
 }
Beispiel #2
0
<?php

/**
 * 接口统一入口
 * @author: dogstar 2014-10-04
 */
/** ---------------- 根目录定义,自动加载 ---------------- **/
defined('API_ROOT') || define('API_ROOT', dirname(__FILE__));
//自动加载
require_once API_ROOT . '/../PhalApi.php';
$loader = new PhalApi_Loader(API_ROOT, array('Service'));
date_default_timezone_set('Asia/Shanghai');
PhalApi_Translator::setLanguage('zh_cn');
/** ---------------- 注册&初始化服务组件 ---------------- **/
DI()->loader = $loader;
DI()->config = new PhalApi_Config_File(dirname(__FILE__) . '/Config');
DI()->request = new PhalApi_Request();
DI()->logger = new PhalApi_Logger_Explorer(PhalApi_Logger::LOG_LEVEL_DEBUG | PhalApi_Logger::LOG_LEVEL_INFO | PhalApi_Logger::LOG_LEVEL_ERROR);
DI()->notorm = function () {
    $notorm = new PhalApi_DB_NotORM(DI()->config->get('dbs'), true);
    return $notorm;
};
DI()->cache = function () {
    //$mc = new PhalApi_Cache_Memcached(DI()->config->get('sys.mc'));
    $mc = new Memcached_Mock();
    return $mc;
};
class Memcached_Mock
{
    public $data = array();
    public function __call($method, $params)
Beispiel #3
0
/**
 * 设定语言,SL为setLanguage的简写
 * @param string $language 翻译包的目录名
 */
function SL($language)
{
    PhalApi_Translator::setLanguage($language);
}