コード例 #1
0
ファイル: SimpleTest.php プロジェクト: ligboy/yaf-phpport
 /**
  * @runInSeparateProcess
  */
 public function testCase02()
 {
     if (!defined('YAF_MODE')) {
         //@todo for some reason this need to b true to pass the test
         Yaf_G::iniSet('yaf.use_spl_autoload', true);
         Yaf_G::iniSet('yaf.lowcase_path', false);
     } else {
         ini_set('yaf.use_spl_autoload', false);
         ini_set('yaf.lowcase_path', false);
     }
     $this->assertEquals('CLI', $this->request->getMethod());
     $this->assertEquals('index', $this->request->getModuleName());
     $this->assertEquals('dummy', $this->request->getControllerName());
     $this->assertEquals('index', $this->request->getActionName());
     $this->assertFalse($this->request->isDispatched());
     $this->assertTrue($this->request->isRouted());
     $this->request->setParam('name', 'Laruence');
     $this->assertEquals('Laruence', $this->request->getParam('name'));
     $this->assertNull($this->request->getParam('non-exists'));
     $this->assertTrue($this->request->isCli());
     $app = new Yaf_Application(array("application" => array("directory" => dirname(__FILE__))));
     try {
         $app->getDispatcher()->dispatch($this->request);
         $this->fail('An Yaf_Exception_LoadFailed_Controller ' . 'exception was not throwed');
     } catch (Exception $e) {
         $this->assertEquals('Could not find controller script ' . dirname(__FILE__) . '/controllers/Dummy.php', $e->getMessage());
     }
 }
コード例 #2
0
ファイル: index.php プロジェクト: alexlis/yaf-lib
<?php

/**
 * php index.php request_uri="/swoole/server"
 * php index.php -cswoole -aserver
 */
ini_set('display_errors', 1);
error_reporting(E_ALL);
date_default_timezone_set('Asia/Shanghai');
define("APPLICATION_PATH", dirname(dirname(__FILE__)));
define("DEBUG_TOOLS", true);
if (DEBUG_TOOLS) {
    require_once APPLICATION_PATH . '/src/library/DebugTools.php';
    #DebugTools::startTimeMemory();
}
require_once APPLICATION_PATH . "/src/tools/hprose-php/Hprose.php";
require_once APPLICATION_PATH . "/src/tools/xapian/xapian.php";
$app = new Yaf_Application(APPLICATION_PATH . "/conf/application.ini");
$request = new Yaf_Request_Simple();
$opt = getopt("c:a:");
if (isset($opt['c']) && isset($opt['a'])) {
    $request->setRequestUri($opt['c'] . "/" . $opt['a']);
}
$app->getDispatcher()->dispatch($request);
if (DEBUG_TOOLS) {
    #DebugTools::useTimeMemory();
}
コード例 #3
0
ファイル: router.php プロジェクト: write123/zyjdSrv
<?php

/**
 * Created by PhpStorm.
 * User: gw
 * Date: 12/9/15
 * Time: 10:27 AM
 */
$request = new Yaf_Request_Simple('index', 'item', 'add', 'Hello', array("a" => 12312));
echo $request->getBaseUri();
print_r($request);