示例#1
0
$t->diag('->getScriptName()');
$request = new myRequest($dispatcher);
$_SERVER['SCRIPT_NAME'] = '/frontend_test.php';
$_SERVER['ORIG_SCRIPT_NAME'] = '/frontend_test2.php';
$t->is($request->getScriptName(), '/frontend_test.php', '->getScriptName() returns the script name');
$request = new myRequest($dispatcher);
unset($_SERVER['SCRIPT_NAME']);
$_SERVER['ORIG_SCRIPT_NAME'] = '/frontend_test2.php';
$t->is($request->getScriptName(), '/frontend_test2.php', '->getScriptName() returns the script name if SCRIPT_NAME not set it use ORIG_SCRIPT_NAME');
$request = new myRequest($dispatcher);
unset($_SERVER['SCRIPT_NAME']);
$t->is($request->getScriptName(), '', '->getScriptName() returns the script name if SCRIPT_NAME and ORIG_SCRIPT_NAME not set it return empty');
// ->getPathInfo()
$t->diag('->getPathInfo()');
$request = new myRequest($dispatcher);
$options = $request->getOptions();
$t->is($options['path_info_key'], 'PATH_INFO', 'check if default path_info_key is PATH_INFO');
$request = new myRequest($dispatcher);
$_SERVER['PATH_INFO'] = '/test/klaus';
$_SERVER['REQUEST_URI'] = '/test/klaus2';
$t->is($request->getPathInfo(), '/test/klaus', '->getPathInfo() returns the url path value');
$request = new myRequest($dispatcher, array(), array(), array('path_info_key' => 'SPECIAL'));
$_SERVER['SPECIAL'] = '/special';
$t->is($request->getPathInfo(), '/special', '->getPathInfo() returns the url path value use path_info_key');
$request->resetPathInfoArray();
$request->resetPathInfoArray();
$request = new myRequest($dispatcher);
$_SERVER['SCRIPT_NAME'] = '/frontend_test.php';
$_SERVER['REQUEST_URI'] = '/frontend_test.php/test/klaus2';
$_SERVER['QUERY_STRING'] = '';
$t->is($request->getPathInfo(), '/test/klaus2', '->getPathInfo() returns the url path value if it not exists use default REQUEST_URI');