Beispiel #1
0
 function setUp()
 {
     Q::import(FIXTURE_DIR . '/core/coll');
     $this->_coll = new QColl('MyItem');
     for ($i = 0; $i < $this->_max; $i++) {
         $this->_coll[] = new MyItem($i);
     }
 }
Beispiel #2
0
 /**
  * 构造函数
  *
  * @param array $app_config
  */
 protected function __construct(array $app_config)
 {
     parent::__construct($app_config);
     $root_dir = $app_config['ROOT_DIR'];
     Q::import($root_dir . '/app/model');
     Q::import($root_dir . '/app');
     require_once $root_dir . '/app/controller/abstract.php';
 }
Beispiel #3
0
 /**
  * 构造函数
  *
  * @param array $app_config
  * @param array $managed_app_config
  */
 protected function __construct($app_config, $managed_app_config)
 {
     parent::__construct($app_config);
     $this->managed_app_config = $managed_app_config;
     Q::import($app_config['ROOT_DIR'] . '/app/model');
     Q::import($app_config['ROOT_DIR'] . '/app');
     Q::import(dirname(Q_DIR) . '/extended');
     require $app_config['ROOT_DIR'] . '/app/controller/abstract.php';
 }
Beispiel #4
0
 /**
  * 构造函数
  *
  * @param array $managed_app_config
  * @param array $managed_app_ini
  *
  * 构造应用程序对象
  */
 protected function __construct(array $managed_app_config, array $managed_app_ini)
 {
     set_exception_handler(array($this, 'exception_handler'));
     $dir = dirname(__FILE__);
     Q::import($dir . '/app');
     Q::import($dir . '/app/model');
     Q::import($managed_app_config['QEEPHP_DIR'] . '/extended');
     Q::replaceIni('managed_app_config', $managed_app_config);
     Q::replaceIni('managed_app_ini', $managed_app_ini);
 }
Beispiel #5
0
 /**
  * 构造函数
  *
  * @param array $app_config
  *
  * 构造应用程序对象
  */
 protected function __construct(array $app_config)
 {
     // #IFDEF DEBUG
     global $g_boot_time;
     QLog::log('--- STARTUP TIME --- ' . $g_boot_time, QLog::DEBUG);
     // #ENDIF
     /**
      * 初始化运行环境
      */
     // 禁止 magic quotes
     set_magic_quotes_runtime(0);
     // 处理被 magic quotes 自动转义过的数据
     if (get_magic_quotes_gpc()) {
         $in = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
         while (list($k, $v) = each($in)) {
             foreach ($v as $key => $val) {
                 if (!is_array($val)) {
                     $in[$k][$key] = stripslashes($val);
                     continue;
                 }
                 $in[] =& $in[$k][$key];
             }
         }
         unset($in);
     }
     // 设置异常处理函数
     set_exception_handler(array($this, 'exception_handler'));
     // 初始化应用程序设置
     $this->_app_config = $app_config;
     $this->_initConfig();
     Q::replaceIni('app_config', $app_config);
     // 设置默认的时区
     date_default_timezone_set(Q::ini('l10n_default_timezone'));
     // 设置 session 服务
     if (Q::ini('runtime_session_provider')) {
         Q::loadClass(Q::ini('runtime_session_provider'));
     }
     // 打开 session
     if (Q::ini('runtime_session_start')) {
         session_start();
         // #IFDEF DEBUG
         QLog::log('session_start()', QLog::DEBUG);
         QLog::log('session_id: ' . session_id(), QLog::DEBUG);
         // #ENDIF
     }
     // 导入类搜索路径
     Q::import($app_config['APP_DIR']);
     Q::import($app_config['APP_DIR'] . '/model');
     Q::import($app_config['MODULE_DIR']);
     // 注册应用程序对象
     Q::register($this, 'app');
 }
Beispiel #6
0
    /**
     * 执行代码生成器
     */
    function generating()
    {
        if (count($this->_argv) < 2) {
            return self::help();
        }
        $type = array_shift($this->_argv);
        $method_name = 'generate' . $type;
        if (method_exists($this, $method_name)) {
            Q::import(dirname(dirname(dirname(__FILE__))) . '/extended');
            return call_user_func(array($this, $method_name), $this->_argv);
        } else {
            echo <<<EOT

[ERROR] Invalid generate type.

EOT;
            return self::help();
        }
    }
Beispiel #7
0
<?php

// $Id: all.php 2242 2009-02-16 21:26:30Z dualface $
Q::import(dirname(dirname(__FILE__)));
class UT_All extends QTest_UnitTest_TestSuite_Abstract
{
    static function suite()
    {
        $suite = new UT_All('UT_Core_Suite');
        $suite->addTestSuite(UT_Core_All::suite());
        $suite->addTestSuite(UT_Form_All::suite());
        return $suite;
    }
}
Beispiel #8
0
 *
 * @{
 */
if (defined('Q_VERSION')) {
    return;
}
//! QeePHP 框架的版本号
define('Q_VERSION', '2.0');
//! QeePHP 框架所在绝对路径
define('Q_DIR', dirname(__FILE__));
//! DIRECTORY_SEPARATOR 的简写
define('DS', DIRECTORY_SEPARATOR);
//! CURRENT_TIMESTAMP 定义为当前时间,减少框架调用 time() 的次数
define('CURRENT_TIMESTAMP', time());
// 设置对象的自动载入
Q::import(Q_DIR);
spl_autoload_register(array('Q', 'loadClass'));
/**
 * 类 Q 提供 QeePHP 框架的基本服务
 *
 * 包括:
 *   - @ref config
 *   - @ref loader
 *   - @ref registry
 *   - @ref cache
 *   - @ref common
 */
abstract class Q
{
    /**
     * 指示应用程序运行模式
 protected function setUp()
 {
     Q::import(FIXTURE_DIR . '/orm');
     $this->_conn = QDB::getConn();
     $this->_conn->startTrans();
 }
Beispiel #10
0
 /**
  * @dataProvider controlProvider
  */
 function testControl($type)
 {
     Q::import(FIXTURE_DIR . '/core/control');
     $control = Q::control($type);
     $this->assertType('Control_' . $type, $control);
 }
 function setUp()
 {
     Q::import(FIXTURE_DIR . '/core', true);
 }
Beispiel #12
0
<?php

// $Id$
/**
 * 单元测试公用初始化文件
 */
require_once 'PHPUnit/Framework.php';
if (defined('TEST_INIT')) {
    return;
}
define('TEST_INIT', true);
date_default_timezone_set('Asia/ShangHai');
require dirname(__FILE__) . '/../../library/q.php';
spl_autoload_register(array('Q', 'loadClass'));
Q::setIni('runtime_cache_dir', dirname(__FILE__) . '/../../tmp');
Q::setIni('log_writer_dir', dirname(__FILE__) . '/../../tmp');
define('FIXTURE_DIR', dirname(dirname(__FILE__)) . DS . 'fixture');
Q::import(FIXTURE_DIR);
abstract class QTest_UnitTest_Abstract extends PHPUnit_Framework_TestCase
{
    protected function assertEmpty($var, $msg = '')
    {
        $this->assertTrue(empty($var), $msg);
    }
}
Beispiel #13
0
    $error = array();
    $appid = preg_replace('[^a-z0-9_]', '', $_POST['appid']);
    if (!$appid || $appid != $_POST['appid']) {
        $error[] = sprintf('设置的应用程序名 "%s" 无效.', $appid);
    }
    $parent_dir = trim($_POST['parent_dir']);
    $p = realpath($parent_dir);
    if (!$parent_dir || $p == dirname(__FILE__) || !is_dir($p)) {
        $error[] = sprintf('设置的目录名 "%s" 无效.', $parent_dir);
    } else {
        $parent_dir = $p;
    }
    if (empty($error)) {
        // 创建应用程序
        require dirname(dirname(__FILE__)) . '/library/q.php';
        Q::import(dirname(dirname(__FILE__)) . '/commands');
        ob_start();
        $argv = array(__FILE__, $parent_dir, $appid);
        $runner = new Chili_Runner_Cli($argv);
        $runner->run();
        $output = ob_get_clean();
        $appid = $parent_dir = '';
    }
} else {
    $error = array();
    $appid = '';
    $parent_dir = '';
    $output = '';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Beispiel #14
0
<?php

/////////////////////////////////////////////////////////////////////////////
// QeePHP Framework
//
// Copyright (c) 2005 - 2008 QeeYuan China Inc. (http://www.qeeyuan.com)
//
// 许可协议,请查看源代码中附带的 LICENSE.TXT 文件,
// 或者访问 http://www.qeephp.org/ 获得详细信息。
/////////////////////////////////////////////////////////////////////////////
/**
 * 用于创建一个应用程序骨架的脚本
 *
 * @package commands
 * @version $Id: chili.php 222 2008-03-06 15:03:16Z dualface $
 */
$dir = dirname(dirname(__FILE__));
require dirname($dir) . '/library/q.php';
Q::import($dir);
$runner = new Chili_Runner_Cli($argv);
$runner->run();
Beispiel #15
0
<?php

/**
 * 创建开发者手册
 */
require dirname(__FILE__) . '/../library/q.php';
$dir = dirname(__FILE__);
Q::import($dir);
Q::import($dir . '/command');
Q::import($dir . '/command/book');
Q::import($dir . '/_vendor/zf');
Q::changeIni('vendor_dir', dirname(__FILE__) . DS . '_vendor');
if (!isset($argv[2])) {
    echo <<<EOT

php gen_book.php <source_dir> <output_dir> [mode]

syntax:
    mode: "online", "offline" or "chm", online is default



EOT;
    exit(-1);
}
$source_dir = $argv[1];
$output_dir = $argv[2];
if (isset($argv[3])) {
    $mode = strtolower(trim($argv[3]));
} else {
    $mode = 'online';
Beispiel #16
0
php chili.php <appid> [...]

syntax:
    php scripts/chili.php <appid> [dest_dir] [tpl_name]

examples:
    php scripts/chili.php myapp
    php scripts/chili.php myapp d:\\www
    php scripts/chili.php myapp d:\\www tianchi_v



EOT;
        return 0;
    }
}
/**
 * 启动脚本
 */
if (!isset($argv)) {
    echo <<<EOT
ERR: PHP running command line without \$argv.

EOT;
    exit;
}
$root_dir = dirname(dirname(dirname(__FILE__)));
require $root_dir . '/library/q.php';
Q::import($root_dir . '/extended');
array_shift($argv);
CliChili::generate($argv);
Beispiel #17
0
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://qeephp.org/license/new-bsd
 *
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to supprt@qeeyuan.com so we can send you a copy immediately.
 *
 * Copyright (c) 2006-2008 QeeYuan Technologies Ltd. Inc. (http://www.qeeyuan.com)
 */
/**
 * 针对 ActiveRecord 的单元测试
 */
require_once dirname(__FILE__) . '/../../_include.php';
Q::import(FIXTURE_DIR . DS . 'model');
class QDB_ActiveRecord_Test extends PHPUnit_Framework_TestCase
{
    /**
     * @var QDB_Adapter_Abstract
     */
    protected $_conn;
    protected function setUp()
    {
        $dsn = Q::getIni('db_dsn_pool/default');
        if (empty($dsn)) {
            Q::setIni('db_dsn_pool/default', Q::getIni('db_dsn_mysql'));
        }
        $this->_conn = QDB::getConn();
        $this->_conn->startTrans();
    }
Beispiel #18
0
<?php

// $Id$
if (empty($_GET['name'])) {
    echo 'invalid parameters';
    exit;
}
require MANAGED_APP_ROOT_DIR . '/config/boot.php';
Q::import(dirname(__FILE__) . '/../../');
$generator = new QGenerator_Controller(ROOT_DIR);
$opts = array($_GET['name']);
$generator->execute($opts);
Beispiel #19
0
<?php

/**
 * 创建 API 文档
 */
require dirname(__FILE__) . '/../library/q.php';
Q::import(dirname(__FILE__));
Q::import(dirname(__FILE__) . '/command');
Q::import(dirname(__FILE__) . '/command/api');
Q::changeIni('vendor_dir', dirname(__FILE__) . DS . '_vendor');
$source_dir = Q_DIR;
$docs_dir = dirname(__FILE__) . '/source/api';
$output_dir = dirname(__FILE__) . '/output/api';
$excludes = array('_config', '_resources', '_vendor');
if (isset($argv[1])) {
    $output_dir = $argv[1];
}
if (isset($argv[2])) {
    $mode = strtolower(trim($argv[2]));
} else {
    $mode = 'online';
}
Command_API::create()->sourceDir($source_dir)->docsDir($docs_dir)->outputDir($output_dir)->excludes($excludes)->docmode($mode)->execute();
Beispiel #20
0
 /**
  * 构造函数
  *
  * @param QApplication_Module $module
  */
 protected function __construct(QApplication_Module $module)
 {
     $module_name = $module->moduleName();
     $appid = $module->APPID();
     self::$_instances[$appid][$module_name] = $this;
     $this->_app = QApplication_Abstract::app($appid);
     $this->_module = $module;
     if ($module_name == QApplication_Module::DEFAULT_MODULE_NAME) {
         // 初始化应用程序默认的上下文对象
         $this->_config = (require Q_DIR . '/_config/default_config.php');
         $this->setIni($module->config());
     } else {
         // 构造其他模块的上下文对象
         $root = self::$_instances[$appid][QApplication_Module::DEFAULT_MODULE_NAME];
         $this->module_name = $module_name;
         $this->namespace = $root->namespace;
         $this->controller_name = $root->controller_name;
         $this->action_name = $root->action_name;
         $this->_router = $root->router();
         $this->_params = $root->_params;
         $this->_parent = $root;
         // 载入该模块的配置
         $this->_config = $module->config();
         $app_config = QApplication_Abstract::getAppConfig($appid);
         Q::import($app_config['ROOT_DIR'] . "/modules/{$module_name}/model");
         Q::import($app_config['ROOT_DIR'] . "/modules/{$module_name}");
     }
     $this->_name = $module_name;
     $this->_initOneTime();
     $this->_prepare();
 }
Beispiel #21
0
 function setUp()
 {
     Q::import(FIXTURE_DIR . '/form');
 }
Beispiel #22
0
    $appid = preg_replace('[^a-z0-9_]', '', $_POST['appid']);
    if (!$appid || $appid != $_POST['appid']) {
        $error[] = sprintf('设置的应用程序名 "%s" 无效.', $appid);
    }
    $parent_dir = trim($_POST['parent_dir']);
    $p = realpath($parent_dir);
    if (!$parent_dir || $p == dirname(__FILE__) || !is_dir($p)) {
        $error[] = sprintf('设置的目录名 "%s" 无效.', $parent_dir);
    } else {
        $parent_dir = $p;
    }
    $tpl_name = trim($_POST['tpl_name']);
    if (empty($error)) {
        // 创建应用程序
        require dirname(dirname(__FILE__)) . '/library/q.php';
        Q::import(dirname(dirname(__FILE__)) . '/extended');
        ob_start();
        $generator = new QGenerator_Application();
        $generator->generate($appid, $parent_dir, $tpl_name);
        $output = ob_get_clean();
        $appid = $parent_dir = '';
    }
} else {
    $error = array();
    $appid = '';
    $parent_dir = '';
    $output = '';
}
$tpl_list = (require dirname(dirname(__FILE__)) . '/extended/qgenerator/_templates/apps/apptpl_list.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">