public function setUp() { parent::setUp(); App::build(array('Plugin' => array(CakePlugin::path('Extensions') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)), App::PREPEND); $this->CroogoPlugin = new CroogoPlugin(); $this->_mapping = array(1346748762 => array('version' => 1346748762, 'name' => '1346748762_first', 'class' => 'First', 'type' => 'app', 'migrated' => '2012-09-04 10:52:42'), 1346748933 => array('version' => 1346748933, 'name' => '1346748933_addstatus', 'class' => 'AddStatus', 'type' => 'app', 'migrated' => '2012-09-04 10:55:33')); }
/** +---------------------------------------------------------- * 应用程序初始化 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ public static function run() { // 设定错误和异常处理 set_error_handler(array('App', "appError")); set_exception_handler(array('App', "appException")); //[RUNTIME] // 检查项目是否编译过 // 在部署模式下会自动在第一次执行的时候编译项目 if (defined('RUNTIME_MODEL')) { // 运行模式无需载入项目编译缓存 } elseif (is_file(RUNTIME_PATH . '~app.php')) { // 直接读取编译后的项目文件 C(include RUNTIME_PATH . '~app.php'); } else { // 预编译项目 App::build(); } //[/RUNTIME] // 取得模块和操作名称 define('MODULE_NAME', isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : C('DEFAULT_MODULE')); define('ACTION_NAME', isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : C('DEFAULT_ACTION')); // 执行操作 R(MODULE_NAME, ACTION_NAME); // 保存日志记录 if (C('LOG_RECORD')) { Log::save(); } return; }
/** * testRenderWithView method * * @return void */ public function testRenderWithView() { App::build(array( 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) )); $Request = new CakeRequest(null, false); $Request->params['named'] = array('page' => 2); $Response = new CakeResponse(); $Controller = new Controller($Request, $Response); $Controller->name = $Controller->viewPath = 'Posts'; $data = array( 'User' => array( 'username' => 'fake' ), 'Item' => array( array('name' => 'item1'), array('name' => 'item2') ) ); $Controller->set('user', $data); $View = new JsonView($Controller); $View->helpers = array('Paginator'); $output = $View->render('index'); $expected = json_encode(array('user' => 'fake', 'list' => array('item1', 'item2'), 'paging' => array('page' => 2))); $this->assertSame($expected, $output); $this->assertSame('application/json', $Response->type()); }
public function testThemeAndPluginInclusion() { App::build(array('Plugin' => array($this->_testFiles . 'Plugin' . DS), 'View' => array($this->_testFiles . 'View' . DS))); CakePlugin::load('TestAsset'); $settings = array('paths' => array(), 'theme' => 'Red'); $this->filter->settings($settings); $this->_themeDir = $this->_testFiles . DS . 'View' . DS . 'Themed' . DS . $settings['theme'] . DS; $content = file_get_contents($this->_themeDir . 'webroot' . DS . 'theme.js'); $result = $this->filter->input('theme.js', $content); $expected = <<<TEXT var Theme = new Class({ }); var ThemeInclude = new Class({ }); var Plugin = new Class({ }); TEXT; $this->assertTextEquals($expected, $result); }
/** +---------------------------------------------------------- * 应用程序初始化 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ public static function run() { // 设定错误和异常处理 set_error_handler(array('App', "appError")); set_exception_handler(array('App', "appException")); //[RUNTIME] // 检查项目是否编译过 // 在部署模式下会自动在第一次执行的时候编译项目 if (defined('RUNTIME_MODEL')) { // 运行模式无需载入项目编译缓存 } elseif (is_file(RUNTIME_PATH . '~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~app.php') > filemtime(CONFIG_PATH . 'config.php'))) { // 直接读取编译后的项目文件 C(include RUNTIME_PATH . '~app.php'); } else { // 预编译项目 App::build(); } //[/RUNTIME] //导入类库 Vendor('Zend.Amf.Server'); //实例化AMF $server = new Zend_Amf_Server(); $actions = explode(',', C('APP_AMF_ACTIONS')); foreach ($actions as $action) { $server->setClass($action . 'Action'); } echo $server->handle(); // 保存日志记录 if (C('LOG_RECORD')) { Log::save(); } return; }
public function setUp() { parent::setUp(); App::build(['Model' => [CakePlugin::path('Tools') . 'Test' . DS . 'test_app' . DS . 'Model' . DS]], App::RESET); $this->Comment = ClassRegistry::init('BitmaskedComment'); $this->Comment->Behaviors->load('Tools.Bitmasked', ['mappedField' => 'statuses']); }
/** * __construct * * @param object $request * @param object $response */ public function __construct($request = null, $response = null) { parent::__construct($request, $response); App::uses('OvenConfig', 'Oven.Lib'); new OvenConfig(); App::build(array('View' => array(App::pluginPath('Oven') . 'Lib' . DS . 'View' . DS)), App::PREPEND); }
/** * start Case - switch view paths * * @return void **/ function startCase() { $this->_viewPaths = App::build('views'); App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS, APP . 'plugins' . DS . 'debug_kit' . DS . 'views' . DS, ROOT . DS . LIBS . 'view' . DS)), true); $this->_debug = Configure::read('debug'); $this->firecake =& FireCake::getInstance(); }
/** * Sets the plugins folder for this test * * @return void */ public function setUp() { parent::setUp(); App::build(array( 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) ), App::RESET); App::objects('plugins', null, false); }
/** * Initializes configure and runs the bootstrap process. * Bootstrapping includes the following steps: * * - Setup App array in Configure. * - Include app/Config/core.php. * - Configure core cache configurations. * - Load App cache files. * - Include app/Config/bootstrap.php. * - Setup error/exception handlers. * * @param bool $boot Whether to do bootstrapping. * * @return void */ public static function bootstrap($boot = TRUE) { if ($boot) { static::_appDefaults(); if (!(include APP . 'Config' . DS . 'core.php')) { trigger_error(__d('cake_dev', "Can't find application core file. Please create %s, and make sure it is readable by PHP.", APP . 'Config' . DS . 'core.php'), E_USER_ERROR); } App::init(); App::$bootstrapping = FALSE; App::build(); $exception = array('handler' => 'ErrorHandler::handleException'); $error = array('handler' => 'ErrorHandler::handleError', 'level' => E_ALL & ~E_DEPRECATED); if (PHP_SAPI === 'cli') { App::uses('ConsoleErrorHandler', 'Console'); $console = new ConsoleErrorHandler(); $exception['handler'] = array($console, 'handleException'); $error['handler'] = array($console, 'handleError'); } static::_setErrorHandlers($error, $exception); if (!(include APP . 'Config' . DS . 'bootstrap.php')) { trigger_error(__d('cake_dev', "Can't find application bootstrap file. Please create %s, and make sure it is readable by PHP.", APP . 'Config' . DS . 'bootstrap.php'), E_USER_ERROR); } restore_error_handler(); static::_setErrorHandlers(static::$_values['Error'], static::$_values['Exception']); // Preload Debugger + CakeText in case of E_STRICT errors when loading files. if (static::$_values['debug'] > 0) { class_exists('Debugger'); class_exists('CakeText'); } } }
/** * setUp method */ public function setUp() { parent::setUp(); App::build(array('Plugin' => array(CakePlugin::path('Migrations') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)), APP::RESET); $this->connection = 'test'; $this->Migrations = new Migrations($this->connection); }
public function setUp() { App::build(array('View' => array(App::pluginPath('Asset') . 'Test' . DS . 'test_app' . DS . 'View' . DS), 'Plugin' => array(App::pluginPath('Asset') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)), App::RESET); $this->path = App::pluginPath('Asset') . 'Test' . DS . 'test_app' . DS . 'webroot' . DS; $this->file = $this->path . 'css' . DS . 'default.css'; $this->Asset = new CssAsset('css/default.css', $this->file, $this->path); }
public function setUp() { parent::setUp(); $this->_pluginPath = App::pluginPath('AssetCompress'); $this->testConfig = $this->_pluginPath . 'Test' . DS . 'test_files' . DS . 'Config' . DS . 'integration.ini'; $map = array( 'TEST_FILES/' => $this->_pluginPath . 'Test' . DS . 'test_files' . DS ); App::build(array( 'Plugin' => array($map['TEST_FILES/'] . 'Plugin' . DS ) )); CakePlugin::load('TestAssetIni'); AssetConfig::clearAllCachedKeys(); $config = AssetConfig::buildFromIniFile($this->testConfig, $map); $config->filters('js', null, array()); $this->Compressor = $this->getMock('AssetCompressor', array('_getConfig')); $this->Compressor->expects($this->atLeastOnce()) ->method('_getConfig') ->will($this->returnValue($config)); $this->request = new CakeRequest(null, false); $this->response = $this->getMock('CakeResponse', array('checkNotModified', 'type', 'send')); Configure::write('debug', 2); }
/** * test reading from plugins * * @return void */ function testReadPluginValue() { App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true); $reader = new PhpReader($this->path); $result = $reader->read('TestPlugin.load'); $this->assertTrue(isset($result['plugin_load'])); }
/** * Initializes configure and runs the bootstrap process. * Bootstrapping includes the following steps: * * - Setup App array in Configure. * - Include app/Config/core.php. * - Configure core cache configurations. * - Load App cache files. * - Include app/Config/bootstrap.php. * - Setup error/exception handlers. * * @param boolean $boot * @return void */ public static function bootstrap($boot = true) { if ($boot) { self::write('App', array('base' => false, 'baseUrl' => false, 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR, 'www_root' => WWW_ROOT)); if (!(include APP . 'Config' . DS . 'core.php')) { trigger_error(__d('cake_dev', "Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", APP . 'Config' . DS), E_USER_ERROR); } App::$bootstrapping = false; App::init(); App::build(); if (!(include APP . 'Config' . DS . 'bootstrap.php')) { trigger_error(__d('cake_dev', "Can't find application bootstrap file. Please create %sbootstrap.php, and make sure it is readable by PHP.", APP . 'Config' . DS), E_USER_ERROR); } $level = -1; if (isset(self::$_values['Error']['level'])) { error_reporting(self::$_values['Error']['level']); $level = self::$_values['Error']['level']; } if (!empty(self::$_values['Error']['handler'])) { set_error_handler(self::$_values['Error']['handler'], $level); } if (!empty(self::$_values['Exception']['handler'])) { set_exception_handler(self::$_values['Exception']['handler']); } } }
public function beforeFilter() { $this->Cookie->httpOnly = true; /*Configure Path*/ App::build(array('Model' => array(CAKE_CORE_INCLUDE_PATH . '/Model/Base/', CAKE_CORE_INCLUDE_PATH . '/Model/', APP_DIR . '/Model/', CAKE_CORE_INCLUDE_PATH . '/Model/Form/'), 'Lib' => array(CAKE_CORE_INCLUDE_PATH . '/Lib/'), 'Vendor' => array(CAKE_CORE_INCLUDE_PATH . '/Vendor/'))); /*Autoload Model*/ App::import('Model', array('CommonTable')); /*Autoload Lib*/ App::uses('myTools', 'Lib'); App::uses('myMailer', 'Lib'); App::uses('myError', 'Lib'); /*Autoload table class*/ spl_autoload_register(function ($class) { $classFile1 = CAKE_CORE_INCLUDE_PATH . '/Model/' . $class . '.php'; $classFile2 = CAKE_CORE_INCLUDE_PATH . '/Model/Form/' . $class . '.php'; if (is_file($classFile1)) { require_once $classFile1; } if (is_file($classFile2)) { require_once $classFile2; } }); /*Autoload Lib*/ Configure::load('my'); Configure::load('const'); }
/** * Initialization method. Triggered before the controller's `beforeFilfer` * method but after the model instantiation. * * @param Controller $controller * @param array $settings * @return null * @access public */ public function initialize(Controller $controller) { // Handle loading our library firstly... App::build(array('Vendor' => array(APP . 'Vendor' . DS . 'vexxhost' . DS . 'cloud-flare-api'))); App::import('Vendor', 'cloudflare_api', array('file' => 'vexxhost' . DS . 'cloud-flare-api' . DS . 'class_cloudflare.php')); $this->Cf = new cloudflare_api(Configure::read('CloudFlareApi.email'), Configure::read('CloudFlareApi.apiKey')); }
/** * Initializes configure and runs the bootstrap process. * Bootstrapping includes the following steps: * * - Setup App array in Configure. * - Include app/Config/core.php. * - Configure core cache configurations. * - Load App cache files. * - Include app/Config/bootstrap.php. * - Setup error/exception handlers. * * @param boolean $boot * @return void */ public static function bootstrap($boot = true) { if ($boot) { self::_appDefaults(); if (!(include APP . 'Config' . DS . 'core.php')) { trigger_error(__d('cake_dev', "Can't find application core file. Please create %s, and make sure it is readable by PHP.", APP . 'Config' . DS . 'core.php'), E_USER_ERROR); } App::init(); App::$bootstrapping = false; App::build(); $exception = array('handler' => 'ErrorHandler::handleException'); $error = array('handler' => 'ErrorHandler::handleError', 'level' => E_ALL & ~E_DEPRECATED); self::_setErrorHandlers($error, $exception); if (!(include APP . 'Config' . DS . 'bootstrap.php')) { trigger_error(__d('cake_dev', "Can't find application bootstrap file. Please create %s, and make sure it is readable by PHP.", APP . 'Config' . DS . 'bootstrap.php'), E_USER_ERROR); } restore_error_handler(); self::_setErrorHandlers(self::$_values['Error'], self::$_values['Exception']); // Preload Debugger + String in case of E_STRICT errors when loading files. if (self::$_values['debug'] > 0) { class_exists('Debugger'); class_exists('String'); } } }
/** * setUp * * @return void */ public function setUp() { parent::setUp(); App::build(array('View' => array(CakePlugin::path('Taxonomy') . 'View' . DS)), App::APPEND); $this->VocabulariesController = $this->generate('Taxonomy.Vocabularies', array('methods' => array('redirect'), 'components' => array('Auth' => array('user'), 'Session'))); $this->VocabulariesController->Auth->staticExpects($this->any())->method('user')->will($this->returnCallback(array($this, 'authUserCallback'))); }
/** * tearDown method * * @return void */ public function tearDown() { unset($this->Task); ClassRegistry::flush(); App::build(); parent::tearDown(); }
public function exec($key) { //匿名函数 if ($this->route[$key]['callback'] instanceof Closure) { //反射分析闭包 $reflectionFunction = new \ReflectionFunction($this->route[$key]['callback']); $gets = $this->route[$key]['get']; $args = []; foreach ($reflectionFunction->getParameters() as $k => $p) { if (isset($gets[$p->name])) { //如果GET变量中存在则将GET变量值赋予,也就是说GET优先级高 $args[$p->name] = $gets[$p->name]; } else { //如果类型为类时分析类 if ($dependency = $p->getClass()) { $args[$p->name] = App::build($dependency->name); } else { //普通参数时获取默认值 $args[$p->name] = App::resolveNonClass($p); } } } echo $reflectionFunction->invokeArgs($args); } else { //设置控制器与方法 Request::set('get.' . c('http.url_var'), $this->route[$key]['callback']); Controller::run($this->route[$key]['get']); } }
/** +---------------------------------------------------------- * 应用程序初始化 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ public static function run() { // 设定错误和异常处理 set_error_handler(array('App', "appError")); set_exception_handler(array('App', "appException")); //[RUNTIME] // 检查项目是否编译过 // 在部署模式下会自动在第一次执行的时候编译项目 if (defined('RUNTIME_MODEL')) { // 运行模式无需载入项目编译缓存 } elseif (is_file(RUNTIME_PATH . '~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~app.php') > filemtime(CONFIG_PATH . 'config.php'))) { // 直接读取编译后的项目文件 C(include RUNTIME_PATH . '~app.php'); } else { // 预编译项目 App::build(); } //[/RUNTIME] // 取得模块和操作名称 define('MODULE_NAME', App::getModule()); // Module名称 define('ACTION_NAME', App::getAction()); // Action操作 // 记录应用初始化时间 if (C('SHOW_RUN_TIME')) { $GLOBALS['_initTime'] = microtime(TRUE); } // 执行操作 R(MODULE_NAME, ACTION_NAME); // 保存日志记录 if (C('LOG_RECORD')) { Log::save(); } return; }
public function setUp() { $this->_paths = App::paths(); $app = CakePlugin::path('Menus') . 'Test' . DS . 'test_app' . DS; App::build(array('Controller' => array($app . 'Controller' . DS), 'View' => array($app . 'View' . DS))); $this->generate('MenusTest'); }
/** * Start test * * @return void */ public function setUp() { parent::setUp(); $this->Version = new MigrationVersion(array('connection' => 'test', 'autoinit' => false)); App::build(array('plugins' => CakePlugin::path('Migrations') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)); Configure::write('Config.language', 'en'); }
/** * 拡張BlogHelperを呼び出しに追加 * */ public function blogBlogBeforeRender(CakeEvent $event) { $path = App::pluginPath('ExHelper'); // ヘルパーのパスを追加 App::build(array('View/Helper' => array($path . 'View' . DS . 'Helper' . DS)), APP::APPEND); $Controller = $event->subject(); $Controller->helpers[] = 'ExBlog'; }
public function setUp() { parent::setUp(); App::build(array('Plugin' => array(App::pluginPath('TwigView') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS))); App::build(array('View' => array(App::pluginPath('TwigView') . 'Test' . DS . 'test_app' . DS . 'View' . DS)), App::RESET); CakePlugin::load('TestTwigView'); $this->Loader = new Twig_Loader_Cakephp(); }
/** * setUp * * @return void */ public function setUp() { parent::setUp(); App::build(array('Plugin' => array(CakePlugin::path('Extensions') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), 'View' => array(CakePlugin::path('Extensions') . 'Test' . DS . 'test_app' . DS . 'View' . DS)), App::PREPEND); $this->testPlugin = CakePlugin::path('Extensions') . 'Test' . DS . 'test_files' . DS . 'example_plugin.zip'; $this->testTheme = CakePlugin::path('Extensions') . 'Test' . DS . 'test_files' . DS . 'example_theme.zip'; $this->ExtensionsInstaller = new ExtensionsInstaller(); }
/** * setup callback * * @return void */ public function setUp() { parent::setUp(); $path = CakePlugin::path('CakeExcel') . 'Test' . DS . 'test_app' . DS . 'View' . DS; App::build(array('View' => $path, 'Vendor' => APP . DS . 'vendor' . DS)); $Controller = new ExcelTestController(); $this->View = new ExcelView($Controller); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), 'Console/Command' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS . 'Command' . DS)), App::RESET); CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); $out = new TestStringOutput(); $in = $this->getMock('ConsoleInput', array(), array(), '', false); $this->Shell = $this->getMock('CommandListShell', array('in', '_stop', 'clear'), array($out, $out, $in)); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $this->request = new CakeRequest(null, false); $this->Controller = new ScaffoldViewMockController($this->request); $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader')); App::build(array('View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS), 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS))); CakePlugin::load('TestPlugin'); }