/home/lnzliplg/www/alt-php81-pecl-yaf_3.3.6-1.el8.tar
tests/086.phpt 0000644 00000000440 15173072043 0007120 0 ustar 00 --TEST--
Check for Yaf_Response_HTTP::setRedirect in CLI
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$response = new Yaf_Response_HTTP();
var_dump($response->setRedirect('https://yourdomain.com'));
?>
--EXPECT--
bool(false)
tests/049.phpt 0000644 00000006327 15173072043 0007131 0 ustar 00 --TEST--
Check for Sample application with exception
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
"dispatcher" => array (
"catchException" => true,
),
"library" => array(
),
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Error.php", <<<PHP
<?php
class ErrorController extends Yaf_Controller_Abstract {
public function errorAction(\$exception) {
\$this->_view->msg = \$exception->getMessage();
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<<PHP
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {
public function _initConfig(Yaf_Dispatcher \$dispatcher) {
Yaf_Registry::set("config", Yaf_Application::app()->getConfig());
}
public function _initPlugin(Yaf_Dispatcher \$dispatcher) {
\$dispatcher->registerPlugin(new TestPlugin());
}
public function _initReturn(Yaf_Dispatcher \$dispatcher) {
// \$dispatcher->returnResponse(true);
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/plugins/Test.php", <<<PHP
<?php
class TestPlugin extends Yaf_Plugin_Abstract {
public function routerStartup(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
var_dump("routerStartup");
}
public function routerShutdown(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
var_dump("routerShutdown");
}
public function dispatchLoopStartup(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
var_dump("dispatchLoopStartup");
}
public function preDispatch(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
var_dump("preDispatch");
}
public function postDispatch(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
var_dump("postDispatch");
}
public function dispatchLoopShutdown(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
var_dump("dispatchLoopShutdown");
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function init() {
var_dump("init");
}
public function indexAction() {
var_dump("action");
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml",
"<?php throw new Exception('view exception'); ?>");
mkdir(APPLICATION_PATH . "/views/error/");
file_put_contents(APPLICATION_PATH . "/views/error/error.phtml",
"catched: <?=\$msg?>");
$app = new Yaf_Application($config);
$app->bootstrap()->run();
?>
--CLEAN--
<?php
/* unlink foo2.phtml permission denied */
require "build.inc";
shutdown();
?>
--EXPECTF--
string(13) "routerStartup"
string(14) "routerShutdown"
string(19) "dispatchLoopStartup"
string(11) "preDispatch"
string(4) "init"
string(6) "action"
catched: view exception
tests/bug63438.phpt 0000644 00000002502 15173072043 0007771 0 ustar 00 --TEST--
Bug #63438 (Strange behavior with nested rendering)
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=1
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
function shut_down() {
echo "done";
}
register_shutdown_function("shut_down");
function view($file){
static $view;
$view = new Yaf_View_Simple(dirname(__FILE__));
return $view->render($file);
}
file_put_contents(dirname(__FILE__) . '/outer.phtml', "1 <?php print view('inner.phtml');?> 3\n");
file_put_contents(dirname(__FILE__) . '/inner.phtml', "2");
print (view('outer.phtml'));
file_put_contents(dirname(__FILE__) . '/outer.phtml', "1 <?php \$this->display('inner.phtml');?> 3\n");
print (view('outer.phtml'));
file_put_contents(dirname(__FILE__) . '/outer.phtml', "1 <?php echo \$this->eval('2');?> 3\n");
print (view('outer.phtml'));
file_put_contents(dirname(__FILE__) . '/outer.phtml', "1 <?php \$this->display('inner.phtml');?> 3\n");
file_put_contents(dirname(__FILE__) . '/inner.phtml', "<?php undefined_function(); ?>");
print (view('outer.phtml'));
?>
--CLEAN--
<?php
@unlink(dirname(__FILE__) . '/outer.phtml');
@unlink(dirname(__FILE__) . '/inner.phtml');
?>
--EXPECTF--
1 2 3
1 2 3
1 2 3
Fatal error: Uncaught Error: Call to undefined function undefined_function() in %sinner.phtml:%d
%a
done
tests/004.phpt 0000644 00000000742 15173072043 0007113 0 ustar 00 --TEST--
Check for Yaf_Registry APIs
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$str = "Ageli Platform";
Yaf_Registry::set("name", $str);
unset($str);
var_dump(Yaf_Registry::get("name"));
var_dump(Yaf_Registry::has("name"));
$name = "name";
Yaf_Registry::del($name);
var_dump(Yaf_Registry::get($name));
var_dump(Yaf_Registry::has($name));
?>
--EXPECT--
string(14) "Ageli Platform"
bool(true)
NULL
bool(false)
tests/108.phpt 0000644 00000002620 15173072043 0007115 0 ustar 00 --TEST--
Check for auto response with ErrorController
--SKIPIF--
<?php
if (!extension_loaded("json")) die("skip, json required");
if (!extension_loaded("yaf")) die("skip");
?>
--EXTENSIONS--
json
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
"dispatcher" => array (
"catchException" => true,
),
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Error.php", <<<PHP
<?php
class ErrorController extends Yaf_Controller_Abstract {
public function errorAction(\$exception) {
\$response = \$this->getResponse();
\$response->setBody(json_encode(array(
"code" => \$exception->getCode(),
"msg" => \$exception->getMessage(),
)
));
\$response->response();
return false;
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function init() {
Yaf_Dispatcher::getInstance()->returnResponse(true);
}
}
PHP
);
$app = new Yaf_Application($config);
$response = $app->run();
?>
--CLEAN--
<?php
/* unlink foo2.phtml permission denied */
require "build.inc";
shutdown();
?>
--EXPECTF--
{"code":%d,"msg":"There is no method indexAction in IndexController"}
tests/063.phpt 0000644 00000002400 15173072043 0007111 0 ustar 00 --TEST--
Check for Yaf_Route_Rewrite with dynamic mvc
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$request = new Yaf_Request_Http("/subdir/ctl/act/name/value");
$router = new Yaf_Router();
$route = new Yaf_Route_Rewrite(
"/subdir/:con/:a/*",
array(
"module" => "m",
"controller" => ":1",
"action" => ":a",
)
);
$router->addRoute("subdir", $route)->addRoute("yaf", new Yaf_Route_Rewrite(
"/yaf/:action/*",
array(
"action" => ':action',
"controller" => "index",
)
))->route($request);
var_dump($router->getCurrentRoute());
print_r($request->getParams());
var_dump($request->getActionName());
var_dump($request->getControllerName());
var_dump($request->getModuleName());
$request = new Yaf_Request_Http("/yaf/act/name/value");
$router->route($request);
var_dump($router->getCurrentRoute());
print_r($request->getParams());
var_dump($request->getActionName());
var_dump($request->getControllerName());
var_dump($request->getModuleName());
?>
--EXPECTF--
string(6) "subdir"
Array
(
[con] => ctl
[a] => act
[name] => value
)
string(3) "act"
NULL
string(1) "M"
string(3) "yaf"
Array
(
[action] => act
[name] => value
)
string(3) "act"
string(5) "Index"
NULL
tests/bug61493.phpt 0000644 00000000740 15173072043 0007772 0 ustar 00 --TEST--
Bug #61493 (Can't remove item when using unset() with a Yaf_Config_Simple instance)
--CREDITS--
littlemiaor at gmail dot com
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$config = new Yaf_Config_Simple(array(
'foo' => 'bar',
), false);
unset($config['foo']);
print_r($config);
?>
--EXPECTF--
Yaf_Config_Simple Object
(
[readonly:protected] =>
[config:protected] => Array
(
)
)
tests/029.phpt 0000644 00000000764 15173072043 0007126 0 ustar 00 --TEST--
Check for Yaf_View_Simple::get and clear
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.library="/php/global/dir"
yaf.use_namespace=0
--FILE--
<?php
$view = new Yaf_View_Simple(dirname(__FILE__));
$view->assign("a", "b");
$view->assign("b", "a");
print_r($view->get("a"));
print_r($view->get());
$view->clear("b");
print_r($view->get());
$view->clear();
print_r($view->get());
?>
--EXPECTF--
bArray
(
[a] => b
[b] => a
)
Array
(
[a] => b
)
Array
(
)
tests/087.phpt 0000644 00000003606 15173072043 0007130 0 ustar 00 --TEST--
Check for Yaf_Route_Map with arbitrary urls
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$url = array(
"/", "/foo", "/foo/", "/foo///bar", "//foo//bar", "/foo/bar///",
"/foo/bar/:", "/foo/bar/:/", "/foo///bar/:/name/laruence/age/32",
"foo/bar/:dummy/value:/age/37",
);
$route = new Yaf_Route_Map(true);
foreach ($url as $u) {
$req = new Yaf_Request_Http($u);
$route->route($req);
echo $u, " : ", "m=>", $req->getModuleName(), " c=>", $req->getControllerName(), " a=>", $req->getActionName();
if (($args = $req->getParams())) {
echo " args=>";
foreach ($args as $k => $v) {
echo $k , "->", $v , ",";
}
}
echo "\n";
}
$route = new Yaf_Route_Map(false, ":");
foreach ($url as $u) {
$req = new Yaf_Request_Http($u);
$route->route($req);
echo $u, " : ", "m=>", $req->getModuleName(), " c=>", $req->getControllerName(), " a=>", $req->getActionName();
if (($args = $req->getParams())) {
echo " args=>";
foreach ($args as $k => $v) {
echo $k , "->", $v , ",";
}
}
echo "\n";
}
--EXPECT--
/ : m=> c=> a=>
/foo : m=> c=>Foo a=>
/foo/ : m=> c=>Foo a=>
/foo///bar : m=> c=>Foo_Bar a=>
//foo//bar : m=> c=>Foo_Bar a=>
/foo/bar/// : m=> c=>Foo_Bar a=>
/foo/bar/: : m=> c=>Foo_Bar_: a=>
/foo/bar/:/ : m=> c=>Foo_Bar_: a=>
/foo///bar/:/name/laruence/age/32 : m=> c=>Foo_Bar_:_Name_Laruence_Age_32 a=>
foo/bar/:dummy/value:/age/37 : m=> c=>Foo_Bar_:dummy_Value:_Age_37 a=>
/ : m=> c=> a=>
/foo : m=> c=> a=>foo
/foo/ : m=> c=> a=>foo
/foo///bar : m=> c=> a=>foo_bar
//foo//bar : m=> c=> a=>foo_bar
/foo/bar/// : m=> c=> a=>foo_bar
/foo/bar/: : m=> c=> a=>foo_bar
/foo/bar/:/ : m=> c=> a=>foo_bar
/foo///bar/:/name/laruence/age/32 : m=> c=> a=>foo_bar args=>name->laruence,age->32,
foo/bar/:dummy/value:/age/37 : m=> c=> a=>foo_bar args=>dummy->value:,age->37,
tests/090.phpt 0000644 00000004156 15173072043 0007123 0 ustar 00 --TEST--
Check for view path generating
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
}
public function foo_bar_indexAction() {
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "<?php var_dump('Index'); ?>");
$app = new Yaf_Application($config);
$app->getDispatcher()->getRouter()->AddRoute("map", new Yaf_Route_Map(true));
$request = new Yaf_Request_Http("/");
$app->getDispatcher()->dispatch($request);
/* Foo_Bar_Index controller */
mkdir(APPLICATION_PATH . "/controllers/Foo");
mkdir(APPLICATION_PATH . "/controllers/Foo/Bar");
file_put_contents(APPLICATION_PATH . "/controllers/Foo/Bar/Index.php", <<<PHP
<?php
class Foo_Bar_IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
}
}
PHP
);
mkdir(APPLICATION_PATH . "/views/foo");
mkdir(APPLICATION_PATH . "/views/foo/bar");
mkdir(APPLICATION_PATH . "/views/foo/bar/index");
file_put_contents(APPLICATION_PATH . "/views/foo/bar/index/index.phtml", "<?php var_dump('CFoo_Bar_Index'); ?>");
$request = new Yaf_Request_Http("/Foo/Bar/Index");
$app->getDispatcher()->dispatch($request);
/* Foo_Bar_Index action */
mkdir(APPLICATION_PATH . "/views/index/foo");
mkdir(APPLICATION_PATH . "/views/index/foo/bar");
file_put_contents(APPLICATION_PATH . "/views/index/foo/bar/index.phtml", "<?php var_dump('AFoo_Bar_Index'); ?>");
$app->getDispatcher()->getRouter()->AddRoute("map", new Yaf_Route_Map(false));
$app->getDispatcher()->getRequest()->setDispatched(false)->setRouted(false)->setControllerName("Index");
$app->getDispatcher()->dispatch($request);
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECT--
string(5) "Index"
string(14) "CFoo_Bar_Index"
string(14) "AFoo_Bar_Index"
tests/094.phpt 0000644 00000004245 15173072043 0007126 0 ustar 00 --TEST--
Check for Yaf_Request read/write property
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.use_namespace=0
--FILE--
<?php
function ref_change(&$val) {
$val = "bad";
}
$request = new Yaf_Request_Simple();
foreach (array("method", "module", "controller", "action", "uri", "base_uri", "language", 123) as $k) {
print "Testing $k:\n";
var_dump(@$request->{$k});
$request->{$k} = true;
if (phpversion() >='8.0.0' && $k==123) {
unset($request->{$k});
}
var_dump(@$request->{$k});
$request->{$k} = "inDex";
ref_change($request->{$k});
if (phpversion() >='8.0.0' && $k==123) {
unset($request->{$k});
}
var_dump(@$request->{$k});
echo "\n";
}
var_dump($request);
?>
--EXPECTF--
Testing method:
string(3) "CLI"
string(3) "CLI"
string(5) "inDex"
Testing module:
NULL
NULL
string(5) "Index"
Testing controller:
NULL
NULL
string(5) "Index"
Testing action:
NULL
NULL
string(5) "index"
Testing uri:
string(0) ""
Warning: main(): Modification of Yaf_Request internal property 'uri' is not allowed in %s094.php on line %d
string(0) ""
Warning: main(): Modification of Yaf_Request internal property 'uri' is not allowed in %s094.php on line %d
string(0) ""
Testing base_uri:
NULL
Warning: main(): Modification of Yaf_Request internal property 'base_uri' is not allowed in %s094.php on line %d
NULL
Warning: main(): Modification of Yaf_Request internal property 'base_uri' is not allowed in %s094.php on line %d
NULL
Testing language:
NULL
Warning: main(): Modification of Yaf_Request internal property 'language' is not allowed in %s094.php on line %d
NULL
Warning: main(): Modification of Yaf_Request internal property 'language' is not allowed in %s094.php on line %d
NULL
Testing 123:
NULL
NULL
NULL
object(Yaf_Request_Simple)#1 (10) {
["method"]=>
string(5) "inDex"
["module"]=>
string(5) "Index"
["controller"]=>
string(5) "Index"
["action"]=>
string(5) "index"
["uri:protected"]=>
string(0) ""
["base_uri:protected"]=>
NULL
["dispatched:protected"]=>
bool(false)
["routed:protected"]=>
bool(false)
["language:protected"]=>
string(0) ""
["params:protected"]=>
array(0) {
}
} tests/106.phpt 0000644 00000003565 15173072043 0007124 0 ustar 00 --TEST--
Check for PSR-4 autoloading
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
"library" => array(
"namespace" => array(
"\Zend" => "/lib/Zend/foo",
"\Microsoft\PHP" => "/var/lib/microsoft",
"\Microsoft\ASP" => "/var/lib/asp",
)
),
),
);
$app = new Yaf_Application($config);
$loader = Yaf_Loader::getInstance();
var_dump($loader->getNamespaces());
var_dump($loader->getNamespacePath("\Zend\Foo\Dummy"));
var_dump($loader->getNamespacePath("\Microsoft\Java"));
var_dump($loader->getNamespacePath("\Microsoft\PHP\Framework"));
$loader->registerNamespace("\Google\Robot", "/library/vendor/lib/robot");
var_dump($loader->getNamespacePath("Google\Robot"));
var_dump(class_exists("\Microsoft\PHP\Framework\Dummy"));
var_dump(class_exists("\Microsoft\ASP\Framework\Dummy"));
var_dump(class_exists("\Zend\Foo\Dummy\Bar"));
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
array(2) {
["Zend"]=>
string(13) "/lib/Zend/foo"
["Microsoft"]=>
array(2) {
["PHP"]=>
string(18) "/var/lib/microsoft"
["ASP"]=>
string(12) "/var/lib/asp"
}
}
string(13) "/lib/Zend/foo"
string(%d) "%sapplication%clibrary"
string(18) "/var/lib/microsoft"
string(%d) "%sapplication%clibrary"
Warning: Yaf_Loader::autoload(): Failed opening script /var/lib/microsoft%cFramework%cDummy.php: No such file or directory in %s106.php on line %d
bool(false)
Warning: Yaf_Loader::autoload(): Failed opening script /var/lib/asp%cFramework%cDummy.php: No such file or directory in %s106.php on line %d
bool(false)
Warning: Yaf_Loader::autoload(): Failed opening script /lib/Zend/foo%cFoo%cDummy%cBar.php: No such file or directory in %s106.php on line %d
bool(false)
tests/102.phpt 0000644 00000003117 15173072043 0007111 0 ustar 00 --TEST--
Check for yaf.forward_limit
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
yaf.forward_limit = 10;
--FILE--
<?php
$config = array(
"application" => array(
"directory" => realpath(dirname(__FILE__)),
"modules" => "module",
),
);
class ControllerController extends Yaf_Controller_Abstract {
public function actionAction($from = NULL) {
if (!$from) {
print "starting\n";
} else {
var_dump($from);
}
$this->forward("module", "controller", "index", array("from" => __METHOD__));
return false;
}
public function indexAction($from) {
var_dump($from);
$this->forward("dummy", array("from" => __METHOD__));
return false;
}
public function dummyAction($from) {
var_dump($from);
$this->forward("controller", "action", array("from" => __METHOD__));
return false;
}
}
$app = new Yaf_Application($config);
$request = new Yaf_Request_Http("/module/controller/action");
try {
$app->getDispatcher()->returnResponse(false)->dispatch($request);
} catch (Yaf_Exception $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
starting
string(34) "ControllerController::actionAction"
string(33) "ControllerController::indexAction"
string(33) "ControllerController::dummyAction"
string(34) "ControllerController::actionAction"
string(33) "ControllerController::indexAction"
string(33) "ControllerController::dummyAction"
string(34) "ControllerController::actionAction"
string(33) "ControllerController::indexAction"
string(33) "ControllerController::dummyAction"
The maximum dispatching count 10 is reached
tests/058.phpt 0000644 00000001121 15173072043 0007114 0 ustar 00 --TEST--
check for Yaf_Dispatcher::flushInstantly
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.environ="product"
yaf.use_namespace=0
--FILE--
<?php
define("APPLICATION_PATH", dirname(__FILE__));
$app = new Yaf_Application(APPLICATION_PATH . '/simple.ini');
Yaf_Dispatcher::getInstance()->flushInstantly(true);
var_dump(Yaf_Dispatcher::getInstance()->flushInstantly());
Yaf_Dispatcher::getInstance()->flushInstantly(false);
var_dump(Yaf_Dispatcher::getInstance()->flushInstantly());
?>
--EXPECTF--
bool(true)
bool(false)
tests/084.phpt 0000644 00000002552 15173072043 0007124 0 ustar 00 --TEST--
Check request methods
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
function checkMethod($method) {
$request = new Yaf_Request_Simple($method, "index", "dummy", NULL, array());
echo "checking {$method}...\n";
var_dump($request->isGet());
var_dump($request->isPost());
var_dump($request->isHead());
var_dump($request->isDelete());
var_dump($request->isPut());
var_dump($request->isOptions());
var_dump($request->isPatch());
return;
}
checkMethod("GET");
checkMethod("POST");
checkMethod("HEAD");
checkMethod("DELETE");
checkMethod("PUT");
checkMethod("OPTIONS");
checkMethod("PATCH");
?>
--EXPECTF--
checking GET...
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
checking POST...
bool(false)
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
checking HEAD...
bool(false)
bool(false)
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)
checking DELETE...
bool(false)
bool(false)
bool(false)
bool(true)
bool(false)
bool(false)
bool(false)
checking PUT...
bool(false)
bool(false)
bool(false)
bool(false)
bool(true)
bool(false)
bool(false)
checking OPTIONS...
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(true)
bool(false)
checking PATCH...
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(true)
tests/005.phpt 0000644 00000001653 15173072043 0007116 0 ustar 00 --TEST--
Check for Yaf_Response_Cli APIs
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$response = new Yaf_Response_Cli();
$body = <<<HTML
yaf
HTML;
$string = "header|";
$response->appendBody($body);
$response->prependBody($string);
$response->appendBody("|footer");
$body = $response->getBody();
unset($body);
var_dump(Yaf_Response_Abstract::DEFAULT_BODY);
print_r($response->getBody(NULL));
var_dump($response->getBody(Yaf_Response_Http::DEFAULT_BODY));
unset($string);
var_dump($response->getBody());
echo($response);
echo "\n";
var_dump($response->getBody());
$response->response();
echo "\n";
var_dump($response->getBody());
?>
--EXPECTF--
string(7) "content"
Array
(
[content] => header|yaf|footer
)
string(17) "header|yaf|footer"
string(17) "header|yaf|footer"
header|yaf|footer
string(17) "header|yaf|footer"
header|yaf|footer
string(17) "header|yaf|footer"
tests/079.phpt 0000644 00000001605 15173072044 0007127 0 ustar 00 --TEST--
Autoloading the classes under library
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<<PHP
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {
public function _initTest() {
Yaf_Loader::getInstance()->registerLocalNamespace("Test");
Yaf_Registry::set("test", new Test());
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/library/Test.php", <<<PHP
<?php
class Test {
public function __construct() {
var_dump("okey");
}
}
PHP
);
$app = new Yaf_Application($config);
$response = $app->bootstrap();
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
string(4) "okey"
tests/003.phpt 0000644 00000002373 15173072044 0007115 0 ustar 00 --TEST--
Check for Yaf_Loader local names
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
ini_set("ap.lowcase_path", FALSE);
$loader = Yaf_Loader::getInstance(dirname(__FILE__), dirname(__FILE__) . "/global");
$loader->registerLocalNamespace("Baidu");
$loader->registerLocalNamespace("Sina");
$loader->registerLocalNamespace(array("Wb", "Inf", NULL, array(), "123"));
var_dump($loader->getLocalNamespace());
var_dump($loader->isLocalName("Baidu_Name"));
var_dump($loader->isLocalName("Inf\\Name"));
try {
var_dump($loader->autoload("Baidu_Name"));
} catch (Yaf_Exception_LoadFailed $e) {
var_dump($e->getMessage());
}
try {
var_dump($loader->autoload("Global_Name"));
} catch (Yaf_Exception_LoadFailed $e) {
var_dump($e->getMessage());
}
?>
--EXPECTF--
array(5) {
[0]=>
string(5) "Baidu"
[1]=>
string(4) "Sina"
[2]=>
string(2) "Wb"
[3]=>
string(3) "Inf"
[4]=>
string(3) "123"
}
bool(true)
bool(true)
Warning: Yaf_Loader::autoload(): Failed opening script %sBaidu%cName.php: No such file or directory in %s
bool(true)
Warning: Yaf_Loader::autoload(): Failed opening script %sglobal%cGlobal%cName.php: No such file or directory in %s
bool(true)
tests/018.phpt 0000644 00000004454 15173072044 0007125 0 ustar 00 --TEST--
Bug Yaf_Config_Ini crash due to inaccurate refcount
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$file = dirname(__FILE__) . "/simple.ini";
$config = new Yaf_Config_Ini($file, 'base');
print_r($config);
?>
--EXPECTF--
Yaf_Config_Ini Object
(
[readonly:protected] => 1
[config:protected] => Array
(
[application] => Array
(
[directory] => APPLICATION_PATH/applcation
)
[name] => base
[array] => Array
(
[1] => 1
[name] => name
)
[5] => 5
[routes] => Array
(
[regex] => Array
(
[type] => regex
[match] => ^/ap/(.*)
[route] => Array
(
[controller] => Index
[action] => action
)
[map] => Array
(
[0] => name
[1] => name
[2] => value
)
)
[simple] => Array
(
[type] => simple
[controller] => c
[module] => m
[action] => a
)
[supervar] => Array
(
[type] => supervar
[varname] => c
)
[rewrite] => Array
(
[type] => rewrite
[match] => /yaf/:name/:value
[route] => Array
(
[controller] => Index
[action] => action
)
)
)
)
[filename:protected] => %s
)
tests/021.phpt 0000644 00000001040 15173072044 0007103 0 ustar 00 --TEST--
Check for Yaf_Application error handler
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
define("APPLICATION_PATH", dirname(__FILE__));
$app = new Yaf_Application(
dirname(__FILE__) . "/simple.ini",
'nocatch');
function error_handler($errno, $errstr, $errfile, $errline) {
echo "error occurrd instead of exception threw";
}
$app->getDispatcher()->setErrorHandler("error_handler", E_RECOVERABLE_ERROR);
$app->run();
?>
--EXPECTF--
error occurrd instead of exception threw
tests/051.phpt 0000644 00000001221 15173072044 0007107 0 ustar 00 --TEST--
Fixed bug that segfault while a abnormal object set to Yaf_Route*::route
--SKIPIF--
<?php if (!extension_loaded("yaf") || phpversion() >='8.0.0') print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
error_reporting(E_ALL & ~E_WARNING);
$x = new Yaf_Route_Map(true);
$x->route($x);
$x = new Yaf_Route_Static();
$x->route($x);
$x = new Yaf_Route_Rewrite("#^/test#", array("controller" => "info"), array());
$x->route($x);
$x = new Yaf_Route_Supervar("r");
$x->route($x);
$x = new Yaf_Route_Regex("#^/test#", array("controller" => "info"), array());
$x->route($x);
echo "okey";
?>
--EXPECTF--
okey tests/007.phpt 0000644 00000003405 15173072044 0007116 0 ustar 00 --TEST--
Check for Yaf_Config_Simple APIs
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$config = array(
'section1' => array(
'name' => 'value',
'dummy' => 'foo',
),
'section2' => "laruence",
);
$config1 = new Yaf_Config_Simple($config, true);
print_r($config1);
$config2 = new Yaf_Config_Simple($config, true);
var_dump($config2->readonly());
$config2->new = "value";
var_dump(isset($config->new));
$config3 = new Yaf_Config_Simple($config);
unset($config);
echo "Isset config3 section:";
var_dump(isset($config3["section2"]));
$config3->new = "value";
echo "Config3 readonly:";
var_dump($config3->readonly());
foreach($config3 as $key => $val) {
}
foreach($config3 as $key => $val) {
print_r($key);
print_r("=>");
print_r($val);
print_r("\n");
}
print_r($config3->toArray());
$sick = @new Yaf_Config_Simple([]);
var_dump($sick->__isset(1));
var_dump($sick->__get(2));
$sick->total = 1;
var_dump(count($sick));
var_dump($sick->total);
?>
--EXPECTF--
Yaf_Config_Simple Object
(
[readonly:protected] => 1
[config:protected] => Array
(
[section1] => Array
(
[name] => value
[dummy] => foo
)
[section2] => laruence
)
)
bool(true)
bool(false)
Isset config3 section:bool(true)
Config3 readonly:bool(false)
section1=>Yaf_Config_Simple Object
(
[readonly:protected] =>
[config:protected] => Array
(
[name] => value
[dummy] => foo
)
)
section2=>laruence
new=>value
Array
(
[section1] => Array
(
[name] => value
[dummy] => foo
)
[section2] => laruence
[new] => value
)
bool(false)
NULL
int(1)
int(1)
tests/013.phpt 0000644 00000005517 15173072044 0007121 0 ustar 00 --TEST--
Check for Yaf_Router and Config Routes
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$file = dirname(__FILE__) . "/simple.ini";
$config = new Yaf_Config_Ini($file, 'extra');
$routes = $config->routes;
print_r($routes);
$router = new Yaf_Router();
$router->addConfig($routes);
print_r($router->getRoutes());
?>
--EXPECTF--
Yaf_Config_Ini Object
(
[readonly:protected] => 1
[config:protected] => Array
(
[regex] => Array
(
[type] => regex
[match] => ^/ap/(.*)
[route] => Array
(
[controller] => Index
[action] => action
)
[map] => Array
(
[0] => name
[1] => name
[2] => value
)
)
[simple] => Array
(
[type] => simple
[controller] => c
[module] => m
[action] => a
)
[supervar] => Array
(
[type] => supervar
[varname] => c
)
[rewrite] => Array
(
[type] => rewrite
[match] => /yaf/:name/:value
[route] => Array
(
[controller] => Index
[action] => action
)
)
)
)
Array
(
[_default] => Yaf_Route_Static Object
(
)
[regex] => Yaf_Route_Regex Object
(
[match:protected] => ^/ap/(.*)
[route:protected] => Array
(
[controller] => Index
[action] => action
)
[map:protected] => Array
(
[0] => name
[1] => name
[2] => value
)
[verify:protected] =>
[reverse:protected] =>
)
[simple] => Yaf_Route_Simple Object
(
[module:protected] => m
[controller:protected] => c
[action:protected] => a
)
[supervar] => Yaf_Route_Supervar Object
(
[varname:protected] => c
)
[rewrite] => Yaf_Route_Rewrite Object
(
[match:protected] => /yaf/:name/:value
[route:protected] => Array
(
[controller] => Index
[action] => action
)
[verify:protected] =>
)
)
tests/091.phpt 0000644 00000002075 15173072044 0007123 0 ustar 00 --TEST--
Check for Yaf_Request_getXXX
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--GET--
name=get
--POST--
name=raw
--FILE--
<?php
$_SERVER["name"] = "server";
$_COOKIE["name"] = "cookie";
$_POST["name"] = "post";
$_ENV["name"] = "env";
$_REQUEST["name"] = "request";
$request = new Yaf_Request_Http("/");
var_dump($request->getServer("name"));
var_dump($request->getQuery("name"));
var_dump($request->getCookie("name"));
var_dump($request->getPost("name"));
var_dump($request->getEnv("name"));
var_dump($request->getRequest("name"));
var_dump($request->getRaw());
var_dump(count($request->getServer()));
var_dump(count($request->getQuery()));
var_dump(count($request->getCookie()));
var_dump(count($request->getPost()));
var_dump(count($request->getEnv()));
var_dump(count($request->getRequest()));
?>
--EXPECTF--
string(6) "server"
string(3) "get"
string(6) "cookie"
string(4) "post"
string(3) "env"
string(7) "request"
string(8) "name=raw"
int(%d)
int(%d)
int(%d)
int(%d)
int(%d)
int(%d)
tests/024.phpt 0000644 00000001243 15173072044 0007113 0 ustar 00 --TEST--
Check for Yaf_Loader::getInstace() paramters
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.library="/php/global/dir"
yaf.use_namespace=0
--FILE--
<?php
$loader = Yaf_Loader::getInstance('/foo');
var_dump($loader->getLibraryPath());
var_dump($loader->getLibraryPath(TRUE));
$config = array(
"application" => array(
"directory" => realpath(dirname(__FILE__)),
),
);
$app = new Yaf_Application($config);
$loader = Yaf_Loader::getInstance(NULL, '/bar');
var_dump($loader->getLibraryPath());
var_dump($loader->getLibraryPath(TRUE));
?>
--EXPECTF--
string(4) "/foo"
string(15) "/php/global/dir"
string(%d) "%slibrary"
string(4) "/bar"
tests/023.phpt 0000644 00000003176 15173072044 0007121 0 ustar 00 --TEST--
Check for Yaf_Loader::set/get(library_path)
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
$loader = Yaf_Loader::getInstance('/foo', '/bar');
$loader->registerLocalNamespace(array("Foo"));
$loader->autoload("Foo_Bar");
$loader->autoload("Bar_Foo");
$loader->setLibraryPath("/foobar", FALSE);
$loader->autoload("Foo_Bar");
$loader->autoload("Bar_Foo");
$loader->setLibraryPath("/foobar", TRUE);
$loader->autoload("Foo_Bar");
$loader->autoload("Bar_Foo");
$loader->autoload("Model");
$loader->autoload("Bar_Model");
?>
--EXPECTF--
Warning: Yaf_Loader::autoload(): Failed opening script /foo%cFoo%cBar.php: No such file or directory in %s023.php on line %d
Warning: Yaf_Loader::autoload(): Failed opening script /bar%cBar%cFoo.php: No such file or directory in %s023.php on line %d
Warning: Yaf_Loader::autoload(): Failed opening script /foobar%cFoo%cBar.php: No such file or directory in %s023.php on line %d
Warning: Yaf_Loader::autoload(): Failed opening script /bar%cBar%cFoo.php: No such file or directory in %s023.php on line %d
Warning: Yaf_Loader::autoload(): Failed opening script /foobar%cFoo%cBar.php: No such file or directory in %s023.php on line %d
Warning: Yaf_Loader::autoload(): Failed opening script %cfoobar%cBar%cFoo.php: No such file or directory in %s023.php on line %d
Warning: Yaf_Loader::autoload(): Failed opening script %cfoobar%cModel.php: No such file or directory in %s023.php on line %d
Warning: Yaf_Loader::autoload(): Couldn't load a MVC class unless an Yaf_Application is initialized in %s023.php on line %d
tests/026.phpt 0000644 00000001251 15173072044 0007114 0 ustar 00 --TEST--
Check for Yaf_Response::setBody/prependBody/appendBody
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.library="/php/global/dir"
yaf.use_namespace=0
--FILE--
<?php
$response = new Yaf_Response_Http();
$response->setBody("ell")->appendBody("o")->setBody(" W", "footer")->prependBody("H")->appendBody("orld", "footer");
print_r($response);
echo $response;
?>
--EXPECTF--
Yaf_Response_Http Object
(
[response_code:protected] => 0
[header_sent:protected] =>
[header:protected] => Array
(
)
[body:protected] => Array
(
[content] => Hello
[footer] => World
)
)
Hello World
tests/097.phpt 0000644 00000004775 15173072044 0007142 0 ustar 00 --TEST--
Check for Yaf_Route_Supervar with arbitrary urls
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$url = array(
"/", "/foo", "/foo/", "/foo///bar", "foo/bar", "/foo/bar/",
"/foo/bar/dummy", "/foo///bar/dummy/", "foo/bar/dummy/",
"/my", "/my/", "/my/foo", "/my/foo/", "my/foo/bar", "my/foo/bar/",
"/m/index/index", "/my/foo/bar/dummy/1", "my/foo/bar/dummy/1/a/2/////",
"/my/index/index", "my/index", "/foo/index", "index/foo",
);
$config = array(
"application" => array(
"directory" => '/tmp/',
"modules" => 'Index,My',
),
);
$app = new Yaf_Application($config);
$route = new Yaf_Route_Supervar("var");
foreach ($url as $u) {
$_GET["var"] = $u;
$req = new Yaf_Request_Http($u);
$route->route($req);
echo $u, " : ", "m=>", $req->getModuleName(), " c=>", $req->getControllerName(), " a=>", $req->getActionName();
if (($args = $req->getParams())) {
echo " args=>";
foreach ($args as $k => $v) {
echo $k , "->", $v , ",";
}
}
echo "\n";
}
ini_set("yaf.action_prefer", 1);
$url = array(
"/", "/foo", "/foo/",
"/my", "/my/", "/my/foo", "/my//foo/",
);
foreach ($url as $u) {
$_GET["var"] = $u;
$req = new Yaf_Request_Http($u);
$route->route($req);
echo $u, " : ", "m=>", $req->getModuleName(), " c=>", $req->getControllerName(), " a=>", $req->getActionName();
if (($args = $req->getParams())) {
echo " args=>";
foreach ($args as $k => $v) {
echo $k , "->", $v , ",";
}
}
echo "\n";
}
?>
--EXPECTF--
/ : m=> c=> a=>
/foo : m=> c=>Foo a=>
/foo/ : m=> c=>Foo a=>
/foo///bar : m=> c=>Foo a=>bar
foo/bar : m=> c=>Foo a=>bar
/foo/bar/ : m=> c=>Foo a=>bar
/foo/bar/dummy : m=> c=>Foo a=>bar args=>dummy->,
/foo///bar/dummy/ : m=> c=>Foo a=>bar args=>dummy->,
foo/bar/dummy/ : m=> c=>Foo a=>bar args=>dummy->,
/my : m=> c=>My a=>
/my/ : m=> c=>My a=>
/my/foo : m=> c=>My a=>foo
/my/foo/ : m=> c=>My a=>foo
my/foo/bar : m=>My c=>Foo a=>bar
my/foo/bar/ : m=>My c=>Foo a=>bar
/m/index/index : m=> c=>M a=>index args=>index->,
/my/foo/bar/dummy/1 : m=>My c=>Foo a=>bar args=>dummy->1,
my/foo/bar/dummy/1/a/2///// : m=>My c=>Foo a=>bar args=>dummy->1,a->2,
/my/index/index : m=>My c=>Index a=>index
my/index : m=> c=>My a=>index
/foo/index : m=> c=>Foo a=>index
index/foo : m=> c=>Index a=>foo
/ : m=> c=> a=>
/foo : m=> c=> a=>foo
/foo/ : m=> c=> a=>foo
/my : m=> c=> a=>my
/my/ : m=> c=> a=>my
/my/foo : m=> c=>My a=>foo
/my//foo/ : m=> c=>My a=>foo
tests/issue420.phpt 0000644 00000002244 15173072044 0010166 0 ustar 00 --TEST--
Issue #420 (bug in yaf_dispatcher_get_call_parameters)
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=1
yaf.lowcase_path=0
yaf.throw_exception=0
yaf.catch_exception=1
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function funcAction(\$a = 0, \$b = 1) {
var_dump(\$a, \$b);
return FALSE;
}
}
PHP
);
$app = new Yaf_Application($config);
$req = new Yaf_Request_Simple();
$req->setControllerName('Foo_Bar', false);
var_dump($req->getControllerName());
$req->setControllerName('index');
$req->setActionName('func');
$req->setParam(array('b' => 'the second param'));
$app->getDispatcher()->dispatch($req);
$req->clearParams();
$req->setParam(array('a' => 'the first param'));
$app->getDispatcher()->dispatch($req);
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECT--
string(7) "Foo_Bar"
int(0)
string(16) "the second param"
string(15) "the first param"
int(1)
tests/103.phpt 0000644 00000002620 15173072044 0007111 0 ustar 00 --TEST--
Check for Yaf_Request::set*Name 's second argument
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
yaf.forward_limit = 10;
--FILE--
<?php
$request = new Yaf_Request_Simple();
$request->setModuleName("foo", true);
var_dump($request->getModuleName());
$request->setModuleName("foo", false);
var_dump($request->getModuleName());
$request->setModuleName("foo_bAR", true);
var_dump($request->getModuleName());
$request->setModuleName("foo_bAR", false);
var_dump($request->getModuleName());
$request->setControllerName("foo", true);
var_dump($request->getControllerName());
$request->setControllerName("foo", false);
var_dump($request->getControllerName());
$request->setControllerName("foo_bAR", true);
var_dump($request->getControllerName());
$request->setControllerName("foo_bAR", false);
var_dump($request->getControllerName());
$request->setActionName("Foo", true);
var_dump($request->getActionName());
$request->setActionName("Foo", false);
var_dump($request->getActionName());
$request->setActionName("foo_bAR", true);
var_dump($request->getActionName());
$request->setActionName("foo_bAR", false);
var_dump($request->getActionName());
?>
--EXPECT--
string(3) "Foo"
string(3) "foo"
string(7) "Foo_Bar"
string(7) "foo_bAR"
string(3) "Foo"
string(3) "foo"
string(7) "Foo_Bar"
string(7) "foo_bAR"
string(3) "foo"
string(3) "Foo"
string(7) "foo_bar"
string(7) "foo_bAR"
tests/076.phpt 0000644 00000001742 15173072044 0007126 0 ustar 00 --TEST--
Check for Yaf_Route_Supervar::assemble
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.throw_exception=1
yaf.use_namespace=0
--FILE--
<?php
$router = new Yaf_Router();
$route = new Yaf_Route_Supervar('r');
$router->addRoute("supervar", $route);
var_dump($router->getRoute('supervar')->assemble(
array(
':a' => 'yafaction',
'tkey' => 'tval',
':c' => 'yafcontroller',
':m' => 'yafmodule'
),
array(
'tkey1' => 'tval1',
'tkey2' => 'tval2'
)
));
try {
var_dump($router->getRoute('supervar')->assemble(
array(
':a' => 'yafaction',
'tkey' => 'tval',
':m' => 'yafmodule'
),
array(
'tkey1' => 'tval1',
'tkey2' => 'tval2',
1 => array(),
)
));
} catch (Exception $e) {
var_dump($e->getMessage());
}
--EXPECTF--
string(%d) "?r=/yafmodule/yafcontroller/yafaction&tkey1=tval1&tkey2=tval2"
string(%d) "You need to specify the controller by ':c'"
tests/072.phpt 0000644 00000003615 15173072044 0007123 0 ustar 00 --TEST--
check for Yaf_Response_Http headers function;
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$response = new Yaf_Response_Http();
var_dump($response->setHeader('MyName1', 'Header1'));
var_dump($response->setHeader('MyName2', 'Header2'));
var_dump($response->setHeader('MyName2', 'Header22'));
var_dump($response->setHeader('MyName1', 'Header11', false));
print_r($response);
var_dump($response->setHeader('MyName1', 'Header1'));
var_dump($response->setHeader('MyName3', 'Header31', false, 301));
var_dump($response->setHeader('MyName3', 'Header32', true, 302));
var_dump($response->setHeader('MyName1', 'Header2', false, 302));
var_dump($response->getHeader());
var_dump($response->getHeader('MyName'));
var_dump($response->getHeader('MyName1'));
print_r($response->clearHeaders());
$headers = array(
'MyName1' => 'Header1x',
'MyName2' => 'Header2x',
'MyName3' => 12345
);
var_dump($response->setAllHeaders($headers));
var_dump($response->getHeader());
?>
--EXPECTF--
bool(true)
bool(true)
bool(true)
bool(true)
Yaf_Response_Http Object
(
[response_code:protected] => 0
[header_sent:protected] =>
[header:protected] => Array
(
[MyName1] => Header1, Header11
[MyName2] => Header22
)
[body:protected] => Array
(
)
)
bool(true)
bool(true)
bool(true)
bool(true)
array(3) {
["MyName1"]=>
string(16) "Header1, Header2"
["MyName2"]=>
string(8) "Header22"
["MyName3"]=>
string(8) "Header32"
}
NULL
string(16) "Header1, Header2"
Yaf_Response_Http Object
(
[response_code:protected] => 302
[header_sent:protected] =>
[header:protected] => Array
(
)
[body:protected] => Array
(
)
)
bool(true)
array(3) {
["MyName1"]=>
string(8) "Header1x"
["MyName2"]=>
string(8) "Header2x"
["MyName3"]=>
string(5) "12345"
}
tests/038.phpt 0000644 00000001252 15173072044 0007120 0 ustar 00 --TEST--
Check for Yaf_View_Simple error message outputing
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.library="/php/global/dir"
log_errors=0
display_errors=1
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$view = new Yaf_View_Simple(dirname(__FILE__));
$view->assign("name", "laruence");
$tpl = APPLICATION_PATH . '/tpls/foo.phtml';
file_put_contents($tpl, <<<HTML
<?php
if ((x) { //syntax errors
}
?>
HTML
);
echo $view->render($tpl);
?>
--CLEAN--
<?php
/* unlink foo2.phtml permission denied */
require "build.inc";
shutdown();
?>
--EXPECTF--
Parse error: syntax error, unexpected %s}%c in %sfoo.phtml on line %d tests/056.phpt 0000644 00000001121 15173072044 0007113 0 ustar 00 --TEST--
check for Yaf_Dispatcher::throwException
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.environ="product"
yaf.use_namespace=0
--FILE--
<?php
define("APPLICATION_PATH", dirname(__FILE__));
$app = new Yaf_Application(APPLICATION_PATH . '/simple.ini');
Yaf_Dispatcher::getInstance()->throwException(true);
var_dump(Yaf_Dispatcher::getInstance()->throwException());
Yaf_Dispatcher::getInstance()->throwException(false);
var_dump(Yaf_Dispatcher::getInstance()->throwException());
?>
--EXPECTF--
bool(true)
bool(false)
tests/062.phpt 0000644 00000001242 15173072044 0007114 0 ustar 00 --TEST--
Check for Yaf_View_Simple and application's template directory
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.library="/php/global/dir"
yaf.use_namespace=0
--FILE--
<?php
$view = new Yaf_View_Simple(dirname(__FILE__));
try {
$view = new Yaf_View_Simple("");
} catch (Yaf_Exception_TypeError $e) {
var_dump($e->getMessage());
}
$config = array(
"application" => array(
"directory" => dirname(__FILE__),
),
);
$app = new Yaf_Application($config);
$view = Yaf_Dispatcher::getInstance()->initView("");
var_dump($view->getScriptPath());
?>
--EXPECTF--
string(%d) "Expects an absolute path for templates directory"
NULL
tests/006.phpt 0000644 00000001555 15173072044 0007121 0 ustar 00 --TEST--
Check for Yaf_Route_Static routing
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$request_uri = "/prefix/controller/action/name/laruence/age/28";
$base_uri = "/prefix/";
$request = new Yaf_Request_Http($request_uri, $base_uri);
unset($base_uri);
unset($request_uri);
$route = new Yaf_Route_Static();
var_dump($route->route($request));
print_r($request);
?>
--EXPECTF--
bool(true)
Yaf_Request_Http Object
(
[method] => CLI
[module] =>
[controller] => Controller
[action] => action
[uri:protected] => /prefix/controller/action/name/laruence/age/28
[base_uri:protected] => /prefix
[dispatched:protected] =>
[routed:protected] =>
[language:protected] =>
[params:protected] => Array
(
[name] => laruence
[age] => 28
)
)
tests/085.phpt 0000644 00000000412 15173072044 0007117 0 ustar 00 --TEST--
Check Yaf_Request_Http::getRaw
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--POST--
a=b&c=d
--FILE--
<?php
$request = new Yaf_Request_Http("/");
var_dump($request->getRaw());
?>
--EXPECT--
string(7) "a=b&c=d"
tests/issue232.phpt 0000644 00000000775 15173072044 0010176 0 ustar 00 --TEST--
ISSUE #232 (Segfault with Yaf_Route_Simple)
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.lowcase_path=0
yaf.throw_exception=0
yaf.catch_exception=1
yaf.use_namespace=0
--GET--
c=index
--FILE--
<?php
$router = new Yaf_Route_Simple("m", "c", "a");
$request = new Yaf_Request_Http("/");
$router->route($request);
var_dump($request->getModuleName());
var_dump($request->getControllerName());
var_dump($request->getActionName());
?>
--EXPECTF--
NULL
string(5) "Index"
NULL
tests/050.phpt 0000644 00000002124 15173072044 0007111 0 ustar 00 --TEST--
Check for Sample application with return response
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<<PHP
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {
public function _initReturn(Yaf_Dispatcher \$dispatcher) {
\$dispatcher->returnResponse(true);
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "view");
$app = new Yaf_Application($config);
$response = $app->bootstrap()->run();
var_dump("-------");
echo $response;
?>
--CLEAN--
<?php
/* unlink foo2.phtml permission denied */
require "build.inc";
shutdown();
?>
--EXPECTF--
string(7) "-------"
view
tests/089.phpt 0000644 00000002122 15173072044 0007123 0 ustar 00 --TEST--
Check for Yaf_Config_Ini gets
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$file = dirname(__FILE__) . "/simple.ini";
define("APPLICATION_PATH", __DIR__);
$config = new Yaf_Config_Ini($file);
var_dump(count($config->base));
var_dump(gettype($config->base->application->directory));
var_dump($config->base->routes->rewrite->route->controller);
var_dump($config->base["routes"]["rewrite"]["route"]["controller"]);
var_dump($config->get("base.routes.rewrite.route.controller"));
var_dump($config->base->get("routes.rewrite.match"));
var_dump($config["base.routes.rewrite.route.controllers"]);
$config = new Yaf_Config_Ini($file, "nocatch");
var_dump(count($config));
var_dump($config->get("routes.rewrite.match"));
var_dump($config->application->dispatcher->throwException);
var_dump($config->application["dispatcher"]["catchException"]);
?>
--EXPECTF--
int(5)
string(6) "string"
string(5) "Index"
string(5) "Index"
string(5) "Index"
string(17) "/yaf/:name/:value"
NULL
int(6)
string(15) "/yaf/:name/:age"
string(0) ""
string(1) "1"
tests/011.phpt 0000644 00000001422 15173072045 0007107 0 ustar 00 --TEST--
Check for Yaf_Route_Rewrite routing
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$request = new Yaf_Request_Http("/subdir/ap/1.2/name/value", "/subdir");
$router = new Yaf_Router();
$route = new Yaf_Route_Rewrite(
"/subdir/:name/:version",
array(
"action" => "version",
)
);
$router->addRoute("subdir", $route)->addRoute("ap", new Yaf_Route_Rewrite(
"/ap/:version/*",
array(
"action" => 'ap',
)
))->route($request);
var_dump($router->getCurrentRoute());
var_dump($request->getParam('version'));
var_dump($request->getActionName());
var_dump($request->getControllerName());
var_dump($request->getParam('name'));
?>
--EXPECTF--
string(2) "ap"
string(3) "1.2"
string(2) "ap"
NULL
string(5) "value"
tests/simple.ini 0000644 00000001644 15173072045 0007711 0 ustar 00 [base]
application.directory=APPLICATION_PATH "/applcation"
name = "base"
array.1 = 1
5=5
array.name="name"
routes.regex.type="regex"
routes.regex.match="^/ap/(.*)"
routes.regex.route.controller="Index"
routes.regex.route.action="action"
routes.regex.map.0="name"
routes.regex.map.1="name"
routes.regex.map.2="value"
routes.simple.type="simple"
routes.simple.controller="c"
routes.simple.module="m"
routes.simple.action="a"
routes.supervar.type="supervar"
routes.supervar.varname="c"
routes.rewrite.type="rewrite"
routes.rewrite.match="/yaf/:name/:value"
routes.rewrite.route.controller="Index"
routes.rewrite.route.action="action"
[extra : base ]
value = "2"
name = "extra"
array.name = "new_name"
array.2 = "test"
[product : extra]
[nocatch : extra]
application.dispatcher.throwException=Off
application.dispatcher.catchException=yes
routes.rewrite.match="/yaf/:name/:age"
[envtest]
env=${FOO}
ini=${yaf.directory}
const=FOO
tests/093.phpt 0000644 00000002124 15173072045 0007121 0 ustar 00 --TEST--
Check for numeric keys in view assign
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function init() {}
public function indexAction() {
\$this->getView()->assign("var", "str key");
\$this->getView()->assign(1, "number key");
\$this->getView()->assign(2.3, "float key");
\$this->getView()->display("index/index.phtml", [-1 => "number key", "0x2342" => "hex key"]);
return false;
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "<?php
var_dump(get_defined_vars());
?>");
$app = new Yaf_Application($config);
$app->run();
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
array(1) {
["var"]=>
string(7) "str key"
}
tests/105.phpt 0000644 00000001750 15173072045 0007117 0 ustar 00 --TEST--
Check for Yaf_Application::bootstrap errors
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
$app = new Yaf_Application($config);
$app->bootstrap();
file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<<PHP
PHP
);
$app->bootstrap();
file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<<PHP
<?php
class Bootstrap {}
PHP
);
try {
$app->bootstrap();
} catch (Exception $e) {
var_dump($e->getMessage());
}
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
Warning: Yaf_Application::bootstrap(): Couldn't find bootstrap file %sBootstrap.php in %s105.php on line %d
Warning: Yaf_Application::bootstrap(): Couldn't find class Bootstrap in %sBootstrap.php in %s105.php on line %d
string(%d) "'Bootstrap' is not a subclass of Yaf_Bootstrap_Abstract"
tests/059.phpt 0000644 00000002746 15173072045 0007135 0 ustar 00 --TEST--
Check nesting view render
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<<PHP
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {
public function _initReturn(Yaf_Dispatcher \$dispatcher) {
\$dispatcher->returnResponse(true);
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function init() {
Yaf_Dispatcher::getInstance()->flushInstantly(true);
}
public function indexAction() {
var_dump(\$this->_view->getScriptPath());
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "<?php print_r(\$this); \$this->display('index/sub.phtml', array('content' => 'dummy'));?>");
file_put_contents(APPLICATION_PATH . "/views/index/sub.phtml", "<?php echo \$content; echo \$this->eval('foobar'); ?>");
$app = new Yaf_Application($config);
$response = $app->bootstrap()->run();
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
string(%d) "%sapplication%cviews"
Yaf_View_Simple Object
(
[tpl_dir:protected] => %s
[tpl_vars:protected] => Array
(
)
)
dummyfoobar
tests/010.phpt 0000644 00000032555 15173072045 0007121 0 ustar 00 --TEST--
Check for Yaf_Config_Ini basic usages
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip";
if (version_compare(PHP_VERSION, '7.1.0') <= 0) {
print "skip PHP 7.0 strict_types __construct() output warning";
}
?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
declare(strict_types=1);
$file = dirname(__FILE__) . "/simple.ini";
$config = new Yaf_Config_Ini($file);
print_r($config);
$config = new Yaf_Config_Ini($file, "extra");
print_r($config);
$config = new Yaf_Config_Ini($file);
$config->longtime = 23424234324;
var_dump($config->readonly());
var_dump($config["base.application.directory"]);
foreach($config as $key => $value) {
print_r($key);
}
$sick = @new Yaf_Config_Ini();
var_dump($sick->__isset(1));
var_dump($sick->__get(1));
$sick->total = 1;
var_dump(count($sick));
?>
--EXPECTF--
Yaf_Config_Ini Object
(
[readonly:protected] => 1
[config:protected] => Array
(
[base] => Array
(
[application] => Array
(
[directory] => APPLICATION_PATH/applcation
)
[name] => base
[array] => Array
(
[1] => 1
[name] => name
)
[5] => 5
[routes] => Array
(
[regex] => Array
(
[type] => regex
[match] => ^/ap/(.*)
[route] => Array
(
[controller] => Index
[action] => action
)
[map] => Array
(
[0] => name
[1] => name
[2] => value
)
)
[simple] => Array
(
[type] => simple
[controller] => c
[module] => m
[action] => a
)
[supervar] => Array
(
[type] => supervar
[varname] => c
)
[rewrite] => Array
(
[type] => rewrite
[match] => /yaf/:name/:value
[route] => Array
(
[controller] => Index
[action] => action
)
)
)
)
[extra] => Array
(
[application] => Array
(
[directory] => APPLICATION_PATH/applcation
)
[name] => extra
[array] => Array
(
[1] => 1
[name] => new_name
[2] => test
)
[5] => 5
[routes] => Array
(
[regex] => Array
(
[type] => regex
[match] => ^/ap/(.*)
[route] => Array
(
[controller] => Index
[action] => action
)
[map] => Array
(
[0] => name
[1] => name
[2] => value
)
)
[simple] => Array
(
[type] => simple
[controller] => c
[module] => m
[action] => a
)
[supervar] => Array
(
[type] => supervar
[varname] => c
)
[rewrite] => Array
(
[type] => rewrite
[match] => /yaf/:name/:value
[route] => Array
(
[controller] => Index
[action] => action
)
)
)
[value] => 2
)
[product] => Array
(
[application] => Array
(
[directory] => APPLICATION_PATH/applcation
)
[name] => extra
[array] => Array
(
[1] => 1
[name] => new_name
[2] => test
)
[5] => 5
[routes] => Array
(
[regex] => Array
(
[type] => regex
[match] => ^/ap/(.*)
[route] => Array
(
[controller] => Index
[action] => action
)
[map] => Array
(
[0] => name
[1] => name
[2] => value
)
)
[simple] => Array
(
[type] => simple
[controller] => c
[module] => m
[action] => a
)
[supervar] => Array
(
[type] => supervar
[varname] => c
)
[rewrite] => Array
(
[type] => rewrite
[match] => /yaf/:name/:value
[route] => Array
(
[controller] => Index
[action] => action
)
)
)
[value] => 2
)
[nocatch] => Array
(
[application] => Array
(
[directory] => APPLICATION_PATH/applcation
[dispatcher] => Array
(
[throwException] =>
[catchException] => 1
)
)
[name] => extra
[array] => Array
(
[1] => 1
[name] => new_name
[2] => test
)
[5] => 5
[routes] => Array
(
[regex] => Array
(
[type] => regex
[match] => ^/ap/(.*)
[route] => Array
(
[controller] => Index
[action] => action
)
[map] => Array
(
[0] => name
[1] => name
[2] => value
)
)
[simple] => Array
(
[type] => simple
[controller] => c
[module] => m
[action] => a
)
[supervar] => Array
(
[type] => supervar
[varname] => c
)
[rewrite] => Array
(
[type] => rewrite
[match] => /yaf/:name/:age
[route] => Array
(
[controller] => Index
[action] => action
)
)
)
[value] => 2
)
[envtest] => Array
(
[env] =>
[ini] =>
[const] => FOO
)
)
[filename:protected] => %s
)
Yaf_Config_Ini Object
(
[readonly:protected] => 1
[config:protected] => Array
(
[application] => Array
(
[directory] => APPLICATION_PATH/applcation
)
[name] => extra
[array] => Array
(
[1] => 1
[name] => new_name
[2] => test
)
[5] => 5
[routes] => Array
(
[regex] => Array
(
[type] => regex
[match] => ^/ap/(.*)
[route] => Array
(
[controller] => Index
[action] => action
)
[map] => Array
(
[0] => name
[1] => name
[2] => value
)
)
[simple] => Array
(
[type] => simple
[controller] => c
[module] => m
[action] => a
)
[supervar] => Array
(
[type] => supervar
[varname] => c
)
[rewrite] => Array
(
[type] => rewrite
[match] => /yaf/:name/:value
[route] => Array
(
[controller] => Index
[action] => action
)
)
)
[value] => 2
)
[filename:protected] => %s
)
Warning: Yaf_Config_Ini::__set(): config is readonly in %s010.php on line %d
bool(true)
string(%d) "%sapplcation"
baseextraproductnocatchenvtest
Fatal error: Uncaught ArgumentCountError: Yaf_Config_Ini::__construct() expects at least 1 %s, 0 given in %s010.php:%d
Stack trace:
#0 %s010.php(%d): Yaf_Config_Ini->__construct()
#1 {main}
thrown in %s010.php on line %d
tests/build.inc 0000644 00000001740 15173072045 0007506 0 ustar 00 <?php
define('DIR_ROOT', dirname(__FILE__));
define("APPLICATION_PATH", DIR_ROOT . DIRECTORY_SEPARATOR . 'application');
function shutdown($root = APPLICATION_PATH) {
$dp = opendir($root);
while (($dir = readdir($dp))) {
if (in_array($dir, array('.', '..'))) {
continue;
}
$path = $root . DIRECTORY_SEPARATOR . $dir;
if (is_dir($path)) {
shutdown($path);
} else if (is_file($path)) {
unlink($path);
}
}
rmdir($root);
}
function startup($root = APPLICATION_PATH) {
$dirs = array();
$dirs[] = 'library';
$dirs[] = 'controllers';
$dirs[] = 'actions';
$dirs[] = 'plugins';
$dirs[] = 'models';
$dirs[] = 'views';
$dirs[] = 'views/index';
$dirs[] = 'tpls';
foreach($dirs as $dir){
$dir = $root . DIRECTORY_SEPARATOR . $dir;
if (!file_exists($dir)) {
mkdir($dir, 0755, true);
chmod($dir, 0755);
}
}
}
?>
tests/088.phpt 0000644 00000003007 15173072045 0007126 0 ustar 00 --TEST--
Check for Yaf_Route_Rwrite with arbitrary urls
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$url = array(
"/", "/foo", "//foo/", "/foo/bar", "/foo///",
"/foo/cont/act", "/foo/cont/act/", "/foocont/act",
"/foo/cont//act", "/foo//cont///act//",
"/foo/cont/act//var/value/", "/foo/cont/act//var/value/age",
"/foo/cont/act//var/value/age/12//",
);
$route = new Yaf_Route_Rewrite(
"/foo/:name/:subname/*",
array(
"controller" => ":name",
"action" => ":subname"
)
);
foreach ($url as $u) {
$req = new Yaf_Request_Http($u);
$route->route($req);
echo $u, " : ", "m=>", $req->getModuleName(), " c=>", $req->getControllerName(), " a=>", $req->getActionName();
if (($args = $req->getParams())) {
echo " args=>";
foreach ($args as $k => $v) {
echo $k , "->", $v , ",";
}
}
echo "\n";
}
?>
--EXPECT--
/ : m=> c=> a=>
/foo : m=> c=> a=>
//foo/ : m=> c=> a=>
/foo/bar : m=> c=> a=>
/foo/// : m=> c=> a=>
/foo/cont/act : m=> c=> a=>
/foo/cont/act/ : m=> c=>Cont a=>act args=>name->cont,subname->act,
/foocont/act : m=> c=> a=>
/foo/cont//act : m=> c=> a=>
/foo//cont///act// : m=> c=>Cont a=>act args=>name->cont,subname->act,
/foo/cont/act//var/value/ : m=> c=>Cont a=>act args=>name->cont,subname->act,var->value,
/foo/cont/act//var/value/age : m=> c=>Cont a=>act args=>name->cont,subname->act,var->value,age->,
/foo/cont/act//var/value/age/12// : m=> c=>Cont a=>act args=>name->cont,subname->act,var->value,age->12,
tests/issue163.phpt 0000644 00000002063 15173072045 0010172 0 ustar 00 --TEST--
Issue #163 (forward from init controller)
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=1
yaf.lowcase_path=0
yaf.throw_exception=0
yaf.catch_exception=1
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function init() {
\$this->forward("Index", "Second", "okey");
}
public function indexAction() {
echo "bad";
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/controllers/Second.php", <<<PHP
<?php
class SecondController extends Yaf_Controller_Abstract {
public function okeyAction() {
echo "Okey";
return FALSE;
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "Okey");
$app = new Yaf_Application($config);
$response = $app->run();
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECT--
Okey
tests/issue530.phpt 0000644 00000001304 15173072045 0010165 0 ustar 00 --TEST--
Segfault while exiting in action
--SKIPIF--
<?php
if (!extension_loaded("yaf")) exit("skip");
if (version_compare(PHP_VERSION, "8.0.0", "lt")) exit("skip only PHP8 affected");
?>
--INI--
yaf.use_namespace=0
yaf.use_spl_autoload=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
$app = new Yaf_Application($config);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
echo 'okey'; exit;
}
}
PHP
);
$app->run();
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECT--
okey
tests/054.phpt 0000644 00000001036 15173072045 0007117 0 ustar 00 --TEST--
check for Various segfault
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
try {
$config = new Yaf_Config_Ini(dirname(__FILE__), "test");
} catch (Exception $e) {
var_dump($e->getMessage());
}
$request = new Yaf_Request_Simple(NULL);
var_dump($request->isOptions());
$config = new Yaf_Config_Simple(array());
$config->key();
echo "okey";
?>
--EXPECTF--
string(%d) "Argument is not a valid ini file '%s'"
bool(false)
okey
tests/bug63381.phpt 0000644 00000002212 15173072045 0007766 0 ustar 00 --TEST--
Bug #63381 ($_SERVER['SCRIPT_NAME'] changed by yaf)
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=1
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$server = $_SERVER;
$cookie = $_COOKIE;
$post = $_POST;
$get = $_GET;
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/controllers/Dummy.php", <<<PHP
<?php
class DummyController extends Yaf_Controller_Abstract {
public function indexAction() {
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "");
$app = new Yaf_Application($config);
$response = $app->run();
var_dump($server === $_SERVER);
var_dump($cookie === $_COOKIE);
var_dump($get === $_GET);
var_dump($post === $_POST);
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
bool(true)
bool(true)
bool(true)
bool(true)
tests/080.phpt 0000644 00000002010 15173072045 0007107 0 ustar 00 --TEST--
PHP7 didn't display Error.
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
"bootstrap" => APPLICATION_PATH . "/mybootstrap.php",
),
);
file_put_contents(APPLICATION_PATH . "/mybootstrap.php", <<<PHP
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {
}
PHP
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
geoge();//funciton undefined!
}
}
PHP
);
$app = new Yaf_Application($config);
$app->bootstrap()->run();
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
Fatal error: Uncaught Error: Call to undefined function geoge() in %s:5
Stack trace:
#0 [internal function]: IndexController->indexAction()
#1 %s080.php(%d): Yaf_Application->run()
#2 {main}
thrown in %s on line %d
tests/052.phpt 0000644 00000003107 15173072045 0007116 0 ustar 00 --TEST--
Check for Yaf_Request APis
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.use_namespace=0
--FILE--
<?php
declare(strict_types=1);
try {
$request == new Yaf_Request_Http(new stdClass(), "xxxx", false);
} catch (TypeError $e) {
var_dump($e->getMessage());
}
$request = new Yaf_Request_Http("xxxxxxxxxxxxxxxxxxxxxxxxxxx");
var_dump($request->get("xxx"));
var_dump($request->getQuery("xxx"));
var_dump($request->getServer("xxx"));
var_dump($request->getPost("xxx"));
var_dump($request->getCookie("xxx"));
var_dump($request->getEnv("xxx"));
echo "------default value-------\n";
var_dump($request->get("xxx", "123"));
print_r($request->getQuery("xxx", new stdClass()));
print_r($request->getServer("xxx", array()));
var_dump($request->getPost("xxx", NULL));
var_dump($request->getCookie("xxx"), false);
var_dump($request->getEnv("xxx"), "2.13232");
echo "-----others-----\n";
var_dump($request->isXmlHttpRequest());
var_dump($request->isCli());
var_dump($request->isPost());
echo "------params-------\n";
var_dump($request->getParam("xxxx"));
var_dump($request->getParams());
var_dump($request->setParam("xxxx"));
?>
--EXPECTF--
string(%d) "Yaf_Request_Http::__construct() expects at most 2 %s, 3 given"
NULL
NULL
NULL
NULL
NULL
NULL
------default value-------
string(3) "123"
stdClass Object
(
)
Array
(
)
NULL
NULL
bool(false)
NULL
string(7) "2.13232"
-----others-----
bool(false)
bool(true)
bool(false)
------params-------
NULL
array(0) {
}
Fatal error: Uncaught TypeError: Yaf_Request_Abstract::setParam()%sarray, string given in %s052.php:%d
%a tests/092.phpt 0000644 00000001610 15173072046 0007120 0 ustar 00 --TEST--
Check for base uri detecting
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
$_SERVER["REQUEST_URI"] = "/yaf/c/a";
$_SERVER["SCRIPT_FILENAME"] = "/usr/local/www/yaf/index.php";
$_SERVER["SCRIPT_NAME"] = "/yaf/index.php";
$req = new Yaf_Request_Http();
var_dump($req->getBaseuri());
var_dump($req->getRequestUri());
unset($_SERVER["SCRIPT_NAME"]);
$_SERVER["PHP_SELF"] = "/yaf/index.php";
$req = new Yaf_Request_Http();
var_dump($req->getBaseuri());
var_dump($req->getRequestUri());
unset($_SERVER["REQUEST_URI"]);
unset($_SERVER["PHP_SELF"]);
$_SERVER["PATH_INFO"] = "/c/a";
$req = new Yaf_Request_Http();
var_dump($req->getBaseuri());
var_dump($req->getRequestUri());
?>
--EXPECT--
string(4) "/yaf"
string(8) "/yaf/c/a"
string(4) "/yaf"
string(8) "/yaf/c/a"
string(0) ""
string(4) "/c/a"
tests/036.phpt 0000644 00000005114 15173072046 0007121 0 ustar 00 --TEST--
Check for Yaf_Route_Static with arbitrary urls
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$url = array(
"/", "/foo", "/foo/", "/foo///bar", "foo/bar", "/foo/bar/",
"/foo/bar/dummy", "/foo///bar/dummy/", "foo/bar/dummy/",
"/my", "/my/", "/my/foo", "/my/foo/", "my/foo/bar", "my/foo/bar/",
"/m/index/index", "/my/foo/bar/dummy/1", "my/foo/bar/dummy/1/a/2/////",
"/my/index/index", "my/index", "/foo/index", "index/foo", "//foo///bar///p1////v1////p2/v2/",
);
$config = array(
"application" => array(
"directory" => '/tmp/',
"modules" => 'Index,My',
),
);
$app = new Yaf_Application($config);
$route = Yaf_Dispatcher::getInstance()->getRouter();
foreach ($url as $u) {
$req = new Yaf_Request_Http($u);
$route->route($req);
echo $u, " : ", "m=>", $req->getModuleName(), " c=>", $req->getControllerName(), " a=>", $req->getActionName();
if (($args = $req->getParams())) {
echo " args=>";
foreach ($args as $k => $v) {
echo $k , "->", $v , ",";
}
}
echo "\n";
}
ini_set("yaf.action_prefer", 1);
$url = array(
"/", "/foo", "/foo/",
"/my", "/my/", "/my/foo", "/my//foo/",
);
foreach ($url as $u) {
$req = new Yaf_Request_Http($u);
$route->route($req);
echo $u, " : ", "m=>", $req->getModuleName(), " c=>", $req->getControllerName(), " a=>", $req->getActionName();
if (($args = $req->getParams())) {
echo " args=>";
foreach ($args as $k => $v) {
echo $k , "->", $v , ",";
}
}
echo "\n";
}
?>
--EXPECT--
/ : m=> c=> a=>
/foo : m=> c=>Foo a=>
/foo/ : m=> c=>Foo a=>
/foo///bar : m=> c=>Foo a=>bar
foo/bar : m=> c=>Foo a=>bar
/foo/bar/ : m=> c=>Foo a=>bar
/foo/bar/dummy : m=> c=>Foo a=>bar args=>dummy->,
/foo///bar/dummy/ : m=> c=>Foo a=>bar args=>dummy->,
foo/bar/dummy/ : m=> c=>Foo a=>bar args=>dummy->,
/my : m=> c=>My a=>
/my/ : m=> c=>My a=>
/my/foo : m=> c=>My a=>foo
/my/foo/ : m=> c=>My a=>foo
my/foo/bar : m=>My c=>Foo a=>bar
my/foo/bar/ : m=>My c=>Foo a=>bar
/m/index/index : m=> c=>M a=>index args=>index->,
/my/foo/bar/dummy/1 : m=>My c=>Foo a=>bar args=>dummy->1,
my/foo/bar/dummy/1/a/2///// : m=>My c=>Foo a=>bar args=>dummy->1,a->2,
/my/index/index : m=>My c=>Index a=>index
my/index : m=> c=>My a=>index
/foo/index : m=> c=>Foo a=>index
index/foo : m=> c=>Index a=>foo
//foo///bar///p1////v1////p2/v2/ : m=> c=>Foo a=>bar args=>p1->,v1->,p2->v2,
/ : m=> c=> a=>
/foo : m=> c=> a=>foo
/foo/ : m=> c=> a=>foo
/my : m=> c=> a=>my
/my/ : m=> c=> a=>my
/my/foo : m=> c=>My a=>foo
/my//foo/ : m=> c=>My a=>foo
tests/bug62702.phpt 0000644 00000003272 15173072046 0007772 0 ustar 00 --TEST--
FR #62702 (Make baseuri case-insensitive)
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$router = new Yaf_Route_Static();
$request = new Yaf_Request_Http("/sample", "/sample");
$router->route($request);
var_dump($request->getControllerName());
$request = new Yaf_Request_Http("/Sample/ABC", "/sample");
$router->route($request);
var_dump($request->getControllerName());
$router = new Yaf_Route_Map(true);
$request = new Yaf_Request_Http("/sample/A/B/C", "/sample");
$router->route($request);
var_dump($request->getControllerName());
$request = new Yaf_Request_Http("/sample", "/sAmplE/");
$router->route($request);
var_dump($request->getControllerName());
$router = new Yaf_Route_Regex("#^/test#", array("controller" => "info"), array());
$request = new Yaf_Request_Http("/test/", "/Test");
$router->route($request);
var_dump($request->getControllerName());
$request = new Yaf_Request_Http("/sample/test", "/sAmplE");
$router->route($request);
var_dump($request->getControllerName());
$router = new Yaf_Route_Rewrite("/test", array("controller" => "info"), array());
$request = new Yaf_Request_Http("/test/", "/Test");
$router->route($request);
var_dump($request->getControllerName());
$request = new Yaf_Request_Http("/sample/test", "/sAmplE");
$router->route($request);
var_dump($request->getControllerName());
$router = new Yaf_Route_Rewrite("/sample/", array("controller" => "info"), array());
$request = new Yaf_Request_Http("/sample/test", "/sam");
$router->route($request);
var_dump($request->getControllerName());
?>
--EXPECTF--
NULL
string(3) "Abc"
string(5) "A_B_C"
NULL
NULL
string(4) "Info"
NULL
string(4) "Info"
string(4) "Info"
tests/073.phpt 0000644 00000002704 15173072046 0007124 0 ustar 00 --TEST--
Check for Yaf_Route_Rewrite::assemble
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$router = new Yaf_Router();
$route = new Yaf_Route_Rewrite(
"/product/:name/:id/*",
array(
'controller' => "product",
),
array()
);
$router->addRoute("rewrite", $route);
var_dump($router->getRoute('rewrite')->assemble(
array(
':name' => 'foo',
':id' => 'bar',
':tmpkey1' => 'tmpval1'
),
array(
'tkey1' => 'tval1',
'tkey2' => 'tval2'
)
)
);
var_dump($router->getRoute('rewrite')->assemble(
array(
':name' => 'foo',
':id' => 1,
':tmpkey1' => 'tmpval1'
),
array(
'tkey1' => 'tval1',
'tkey2' => 22222
)
)
);
--EXPECTF--
string(57) "/product/foo/bar/tmpkey1/tmpval1/?tkey1=tval1&tkey2=tval2"
string(55) "/product/foo/1/tmpkey1/tmpval1/?tkey1=tval1&tkey2=22222"
tests/098.phpt 0000644 00000001654 15173072046 0007136 0 ustar 00 --TEST--
Check for Yaf_Bootstrap protected method
--SKIPIF--
<?php
if (!extension_loaded("yaf")) print "skip";
if (!version_compare(PHP_VERSION, "5.3", "ge")) print "skip only for 5.3+";
?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$config = array(
"application" => array(
"directory" => realpath(dirname(__FILE__)),
"dispatcher" => array(
"catchException" => 0,
"throwException" => 0,
),
),
);
class Bootstrap extends Yaf_Bootstrap_Abstract {
protected function _initErrorHandler(Yaf_Dispatcher $dispatcher) {
echo "Bad";
}
}
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
echo "Okey";
return FALSE;
}
}
$app = new Yaf_Application($config);
try {
$app->bootstrap()->run();
} catch (Exception $e) {
var_dump($e->getMessage());
}
?>
--EXPECTF--
Warning: %scannot call protected method Bootstrap::_initErrorHandler() in %s098.php on line %d
Okey
tests/107.phpt 0000644 00000002123 15173072046 0007115 0 ustar 00 --TEST--
Check for Yaf_Dispatcher::setRespone
--SKIPIF--
<?php
if (!extension_loaded("json")) die("skip, json required");
if (!extension_loaded("yaf")) die("skip");
?>
--EXTENSIONS--
json
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
class my_response extends Yaf_Response_Abstract {
public $bodys;
public function appendBody($body, $name = NULL) {
$this->bodys[] = $body;
}
public function response() {
var_dump(json_encode($this->bodys));
}
}
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "custom response");
$app = new Yaf_Application($config);
$app->getDispatcher()->setResponse(new my_response());
$app->run();
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECT--
string(19) "["custom response"]"
tests/074.phpt 0000644 00000001322 15173072046 0007120 0 ustar 00 --TEST--
Check for Yaf_Route_Simple::assemble
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$router = new Yaf_Router();
$route = new Yaf_Route_Simple('m', 'c', 'a');
$router->addRoute("simple", $route);
var_dump($router->getRoute('simple')->assemble(
array(
':a' => 'yafaction',
'tkey' => 'tval',
':c' => 'yafcontroller',
':m' => 'yafmodule'
),
array(
'tkey1' => 'tval1',
'tkey2' => 'tval2'
)
));
--EXPECTF--
string(64) "?m=yafmodule&c=yafcontroller&a=yafaction&tkey1=tval1&tkey2=tval2"
tests/015.phpt 0000644 00000001003 15173072046 0007107 0 ustar 00 --TEST--
Check for Yaf_Exception
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
<?php if (version_compare(PHP_VERSION, "5.3.0", "lt")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$previous = new Yaf_Exception("Previous", 100);
$exception = new Yaf_Exception("Exception", 200, $previous);
var_dump($previous === $exception->getPrevious());
var_dump($exception->getMessage());
var_dump($exception->getPrevious()->getCode());
?>
--EXPECTF--
bool(true)
string(9) "Exception"
int(100)
tests/035.phpt 0000644 00000002011 15173072046 0007111 0 ustar 00 --TEST--
Check for Yaf_View_Simple with short_tag_open
--SKIPIF--
<?php
if (!extension_loaded("yaf")) print "skip";
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
print "skip PHP 5.4 remove short_open_tag";
}
?>
--INI--
short_open_tag = 0
yaf.use_namespace=0
--FILE--
<?php
$view = new Yaf_View_Simple(dirname(__FILE__));
$tpl = dirname(__FILE__) . '/short_tag_test.phtml';
$content = "<?=\$name?>";
file_put_contents($tpl, $content);
echo $view->render($tpl, array('name' => 'template'));
echo "\n";
$view->display($tpl, array('name' => 'template'));
$view = new Yaf_View_Simple(dirname(__FILE__), array("short_tag" => 0));
echo "\n";
var_dump(ini_get("short_open_tag"));
$view->display($tpl, array('name' => 'template'));
echo "\n";
print_r($view);
unlink($tpl);
?>
--EXPECTF--
template
template
string(1) "0"
<?=$name?>
Yaf_View_Simple Object
(
[_tpl_vars:protected] => Array
(
)
[_tpl_dir:protected] => %s
[_options:protected] => Array
(
[short_tag] => 0
)
)
tests/issue513.phpt 0000644 00000005216 15173072046 0010175 0 ustar 00 --TEST--
Check for Custom MVC name
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
"bootstrap" => APPLICATION_PATH . "/cboot.php",
"dispatcher" => array (
"catchException" => true,
),
"library" => array(
),
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Error.php", <<<PHP
<?php
class ErrorController extends Yaf_Controller_Abstract {
public function errorAction(\$exception) {
var_dump(\$exception->getMessage());
return FALSE;
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/cboot.php", <<<PHP
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {
public function _initPlugin(Yaf_Dispatcher \$dispatcher) {
\$dispatcher->registerPlugin(new TestPlugin());
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/plugins/Test.php", <<<PHP
<?php
class TestPlugin extends Yaf_Plugin_Abstract {
public function routerShutdown(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
\$request->setModuleName("CUSTOM", false);
\$request->setControllerName("INDEX", false);
\$request->setActionName("CamelName", false);
return;
}
public function dispatchLoopStartup(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
}
public function preDispatch(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
}
public function postDispatch(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
var_dump(\$request->getControllerName());
var_dump(\$request->getActionName());
}
}
PHP
);
$value = NULL;
@mkdir(APPLICATION_PATH . "/modules");
@mkdir(APPLICATION_PATH . "/modules/CUSTOM");
@mkdir(APPLICATION_PATH . "/modules/CUSTOM/controllers");
@mkdir(APPLICATION_PATH . "/modules/CUSTOM/views");
/* Controller name here should be lowercase anyway? */
@mkdir(APPLICATION_PATH . "/modules/CUSTOM/views/index");
file_put_contents(APPLICATION_PATH . "/modules/CUSTOM/controllers/INDEX.php", <<<PHP
<?php
class INDEXController extends Yaf_Controller_Abstract {
public function CamelNameAction() {
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/modules/CUSTOM/views/index/CamelName.phtml", "<?php var_dump('ok'); ?>");
$app = new Yaf_Application($config);
$app->bootstrap()->run();
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
string(5) "INDEX"
string(9) "CamelName"
string(2) "ok"
tests/issue469.phpt 0000644 00000003674 15173072046 0010215 0 ustar 00 --TEST--
Issue #469 (treat autocontroller as Contorller mistakenly)
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.throw_exception=0
yaf.catch_exception=1
yaf.use_namespace=0
yaf.name_separator=""
--FILE--
<?php
Yaf_Loader::getInstance("/tmp/library");
set_error_handler(function($level, $msg) {
global $is_mvc;
if (strpos($msg, "Couldn't load a MVC class unless") !== false && !$is_mvc) {
var_dump($msg);
} else if (strpos($msg, "Couldn't load a MVC class unless") === false && $is_mvc) {
var_dump($msg);
}
});
function try_load_class($name) {
Yaf_Loader::getInstance()->autoload($name);
}
ini_set("yaf.name_suffix", 1);
$is_mvc = false;
try_load_class("automodel");
try_load_class("autoplugin");
try_load_class("autocontroller");
$is_mvc = true;
try_load_class("autoModel");
try_load_class("autoPlugin");
try_load_class("autoController");
ini_set("yaf.name_suffix", 0);
$is_mvc = false;
try_load_class("modelauto");
try_load_class("pluginauto");
try_load_class("controllerauto");
$is_mvc = true;
try_load_class("Modelauto");
try_load_class("Pluginauto");
try_load_class("Controllerauto");
ini_set("yaf.name_suffix", 1);
ini_set("yaf.name_separator", "_");
$is_mvc = false;
try_load_class("auto_model");
try_load_class("auto_plugin");
try_load_class("auto_controller");
$is_mvc = true;
try_load_class("auto_Model");
try_load_class("auto_Plugin");
try_load_class("auto_Controller");
ini_set("yaf.name_suffix", 0);
$is_mvc = false;
try_load_class("model_auto");
try_load_class("plugin_auto");
try_load_class("controller_auto");
try_load_class("Modelauto");
try_load_class("Pluginauto");
try_load_class("Controllerauto");
$is_mvc = true;
try_load_class("Model_auto");
try_load_class("Plugin_auto");
try_load_class("Controller_auto");
ini_set("yaf.name_separator", "\\");
try_load_class("Model\auto");
try_load_class("\Plugin\auto");
try_load_class("\Controller\auto");
?>
okey
--EXPECT--
okey
tests/100.phpt 0000644 00000004363 15173072046 0007116 0 ustar 00 --TEST--
Check for error conditions of Yaf_Application::constructor
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
try {
$app = new Yaf_Application(fopen(__FILE__, "r"));
} catch (Exception $e) {
var_dump($e->getMessage());
}
var_dump(isset($app));
try {
$app = new Yaf_Application(array(), "r");
} catch (Exception $e) {
var_dump($e->getMessage());
}
var_dump(isset($app));
try {
$app = new Yaf_Application(array("yaf" => 1), "r");
} catch (Exception $e) {
var_dump($e->getMessage());
}
var_dump(isset($app));
try {
$app = new Yaf_Application(array("yaf" => array()), "r");
} catch (Exception $e) {
var_dump($e->getMessage());
}
var_dump(isset($app));
try {
$app = new Yaf_Application(array("yaf" => array("directory" => __DIR__)), fopen(__FILE__, 'r'));
} catch (Error $e) {
if (phpversion() >='8.0.0') {
var_dump('Yaf_Application::__construct() expects parameter 2 to be string, resource given');
}else{
var_dump($e->getMessage());
}
}
var_dump(isset($app));
$app = new Yaf_Application(array("yaf" => array("directory" => APPLICATION_PATH)));
try {
$double = new Yaf_Application(array("yaf" => array("directory" => __DIR__)));
} catch (Exception $e) {
var_dump($e->getMessage());
}
var_dump(isset($double));
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function init() {
Yaf_dispatcher::getInstance()->getApplication()->run();
}
}
PHP
);
try {
$app->run();
} catch (Exception $e) {
var_dump($e->getMessage());
}
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECT--
string(43) "Initialization of application config failed"
bool(false)
string(46) "Expected an array of application configuration"
bool(false)
string(46) "Expected an array of application configuration"
bool(false)
string(55) "Expected 'directory' entry in application configuration"
bool(false)
string(79) "Yaf_Application::__construct() expects parameter 2 to be string, resource given"
bool(false)
string(39) "Only one application can be initialized"
bool(false)
string(30) "Application is already started"
tests/019.phpt 0000644 00000001206 15173072046 0007120 0 ustar 00 --TEST--
Yaf_Router::getCurrent with number key
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$request = new Yaf_Request_Http("/subdir/ap/1.2/name/value", "/subdir");
$router = new Yaf_Router();
$router->addConfig(
array(
array(
"type" => "regex",
"match" => "#^/ap/([^/]*)/*#i",
"route" => array(
array(
"action" => 'ap',
),
),
"map" => array(
1 => 'version',
)
)
)
)->route($request);
var_dump($router->getCurrentRoute());
var_dump($request->getParam("version"));
?>
--EXPECT--
int(0)
string(3) "1.2"
tests/bug76213.phpt 0000644 00000001140 15173072046 0007764 0 ustar 00 --TEST--
Bug #76213 (Memory leaks with yaf_dispatcher_exception_handler)
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$config = array(
"application" => array(
"directory" => realpath(dirname(__FILE__)),
"dispatcher" => array(
"catchException" => 1
)
),
);
$app = new Yaf_Application($config);
try {
$request = new Yaf_Request_Http("/index/admin/login1");
$app->getDispatcher()->dispatch($request);
} catch(Yaf_Exception $e) {
var_dump($e->getMessage());
}
?>
--EXPECTF--
string(%d) "%s"
tests/037.phpt 0000644 00000003572 15173072046 0007130 0 ustar 00 --TEST--
Check for Yaf_Loader and open_basedir
--SKIPIF--
<?php
if (!extension_loaded("yaf")) {
die("skip");
}
if (version_compare(PHP_VERSION, "5.3", "lt")) {
die("skip open_basedir only can be tightened as of 5.3.0");
}
?>
--INI--
yaf.lowcase_path=0
yaf.use_spl_autoload=0
yaf.use_namespace=0
--FILE--
<?php
$dir = __DIR__;
$odir = $dir . "/foo";
var_dump(Yaf_Loader::import("./Dummy.php"));
$loader = Yaf_Loader::getInstance();
var_dump($loader->import("./Dummy.php"));
var_dump($loader->autoload("Dummy"));
file_put_contents($dir . "/Dummy.php", "");
ini_set("open_basedir", $odir);
$loader = Yaf_Loader::getInstance($dir);
$loader->import($dir . "/Dummy.php");
$loader->autoload("Dummy");
?>
--CLEAN--
<?php
unlink(__DIR__ . "/Dummy.php");
?>
--EXPECTF--
Warning: Yaf_Loader::import(): Yaf_Loader need to be initialize first in %s037.php on line %d
bool(false)
bool(false)
Warning: Yaf_Loader::autoload(): Failed opening script %cDummy.php: No such file or directory in %s037.php on line %d
bool(true)
Warning: Yaf_Loader::import(): open_basedir restriction in effect. File(%sDummy.php) is not within the allowed path(s): (%sfoo) in %s037.php on line %d
Warning: Yaf_Loader::import(%sDummy.php): %cailed to open stream: Operation not permitted in %s037.php on line %d
Warning: Yaf_Loader::import(): Failed opening '%sDummy.php' for inclusion (include_path='%s') in %s037.php on line %d
Warning: Yaf_Loader::autoload(): open_basedir restriction in effect. File(%sDummy.php) is not within the allowed path(s): (%sfoo) in %s037.php on line %d
Warning: Yaf_Loader::autoload(%sDummy.php): %cailed to open stream: Operation not permitted in %s037.php on line %d
Warning: Yaf_Loader::autoload(): Failed opening '%sDummy.php' for inclusion (include_path='%s') in %s037.php on line %d
Warning: Yaf_Loader::autoload(): Failed opening script %sDummy.php: Operation not permitted in %s037.php on line %d
tests/061.phpt 0000644 00000002075 15173072047 0007123 0 ustar 00 --TEST--
Bug empty template file interrupts forward chain
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=1
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
\$this->forward("dummy");
}
public function dummyAction() {
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/controllers/Dummy.php", <<<PHP
<?php
class DummyController extends Yaf_Controller_Abstract {
public function indexAction() {
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "");
file_put_contents(APPLICATION_PATH . "/views/index/dummy.phtml", "Dummy");
$app = new Yaf_Application($config);
$response = $app->run();
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
Dummy
tests/060.phpt 0000644 00000002665 15173072047 0007127 0 ustar 00 --TEST--
Check for working with other autoloaders
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=1
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
function my_autoload($class) {
eval("class $class {}");
return TRUE;
}
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<<PHP
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {
public function _initAutoload(Yaf_Dispatcher \$dispatcher) {
spl_autoload_register("my_autoload");
}
public static function errorHandler(\$error, \$errstr) {
var_dump(\$errstr);
}
public function _initErrorHandler(Yaf_Dispatcher \$dispatcher) {
\$dispatcher->setErrorHandler(array("Bootstrap", "errorHandler"));
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
\$obj = new Dummy();
\$this->_view->obj = \$obj;
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "<?php echo get_class(\$obj);?>");
$app = new Yaf_Application($config);
$response = $app->bootstrap()->run();
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
Dummy
tests/048.phpt 0000644 00000006426 15173072047 0007134 0 ustar 00 --TEST--
Check for Sample application
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
"dispatcher" => array (
"catchException" => true,
),
"library" => array(
),
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Error.php", <<<PHP
<?php
class ErrorController extends Yaf_Controller_Abstract {
public function errorAction(\$exception) {
var_dump(\$exception->getMessage());
return FALSE;
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<<PHP
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {
public function _initConfig(Yaf_Dispatcher \$dispatcher) {
Yaf_Registry::set("config", Yaf_Application::app()->getConfig());
}
public function _initPlugin(Yaf_Dispatcher \$dispatcher) {
\$dispatcher->registerPlugin(new TestPlugin());
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/plugins/Test.php", <<<PHP
<?php
class TestPlugin extends Yaf_Plugin_Abstract {
public function routerStartup(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
var_dump("routerStartup");
}
public function routerShutdown(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
var_dump("routerShutdown");
}
public function dispatchLoopStartup(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
var_dump("dispatchLoopStartup");
}
public function preDispatch(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
var_dump("preDispatch");
}
public function postDispatch(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
var_dump("postDispatch");
}
public function dispatchLoopShutdown(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
global \$value;
var_dump("dispatchLoopShutdown, global var is:" . \$value);
}
}
PHP
);
$value = NULL;
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function init() {
var_dump("init");
}
public function indexAction() {
global \$value;
var_dump("action");
var_dump(Yaf_Registry::get("config")->application->dispatcher->catchException);
\$this->getView()->assignRef("ref", \$value);
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml",
"<?php var_dump('view'); \$ref = \"changed\"; ?>");
$app = new Yaf_Application($config);
$app->bootstrap()->run();
?>
--CLEAN--
<?php
/* unlink foo2.phtml permission denied */
require "build.inc";
shutdown();
?>
--EXPECTF--
string(13) "routerStartup"
string(14) "routerShutdown"
string(19) "dispatchLoopStartup"
string(11) "preDispatch"
string(4) "init"
string(6) "action"
bool(true)
string(12) "postDispatch"
string(43) "dispatchLoopShutdown, global var is:changed"
string(4) "view"
tests/068.phpt 0000644 00000002057 15173072047 0007132 0 ustar 00 --TEST--
Check for multi inheritance of section
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$config = new Yaf_Config_Ini(dirname(__FILE__) . "/multi-section.ini");
print_r($config->toArray());
?>
--EXPECTF--
Array
(
[base] => Array
(
[base] => Array
(
[a] => 1
[b] => 2
)
)
[extra] => Array
(
[base] => Array
(
[c] => 3
)
)
[foo] => Array
(
[base] => Array
(
[d] => 4
)
)
[multi] => Array
(
[base] => Array
(
[d] => 4
[a] => 1
[b] => 2
[c] => 3
)
)
[] => Array
(
[base] => Array
(
[d] => 4
)
)
)
tests/109.phpt 0000644 00000003053 15173072047 0007123 0 ustar 00 --TEST--
Check for SIMD build_camel_name
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
$name = array(
'_a_b_cd_1_eF_g_', /* 15 bytes */
'a_b_cd_1_eF_g_h',
'_a_b_cd_1_eF_g_h', /* 16 bytes */
'a_b_cd_1_eF_g_H_',
'_a_b_cd_1_eF_g_h_', /* 17 bytes */
'a_b_cd_1_eF_g_H_i',
'_a_b_cd_1_eF_g_h_1', /* 18 bytes */
'a_b_cd_1_eF_g_H_i1',
'_a_b_cd_1_eF_g_h_iiiiii_J123_u', /* 32 bytes */
'a_b_cd_1_eF_g_h_Jiiiii_j123_kl',
'_a_b_cd_1_eF_g_h_iiiiii_J123k_l1', /* 34 bytes */
'a_b_cd_1_eF_g_h_Jiiiii_j123_uV_L',
);
$request = new Yaf_Request_Simple();
setlocale(LC_ALL, "C");
function build_camel_name($u) {
$u[0] = strtoupper($u[0]);
for($i = 1; $i < strlen($u); $i++) {
if ($u[$i - 1] == '_') {
$u[$i] = strtoupper($u[$i]);
} else {
$u[$i] = strtolower($u[$i]);
}
}
return $u;
}
/* standard test */
foreach ($name as $u) {
$request->setControllerName($u);
if ($request->getControllerName() != build_camel_name($u)) {
echo $u, ": expected: " , build_camel_name($u), "; got: ", $request->getControllerName(), "\n";
}
}
/* random test */
$i = 0;
while ($i++ < 1024) {
$len = rand(1, 64);
$u = str_repeat(' ', $len);
for ($c = 0; $c < $len; $c++) {
@$u[$c] = rand(1, 255);
}
$request->setControllerName($u);
if ($request->getControllerName() != build_camel_name($u)) {
echo $u, ": expected: " , build_camel_name($u), "; got: ", $request->getControllerName(), "\n";
}
}
?>
okey
--EXPECT--
okey
tests/041.phpt 0000644 00000003256 15173072047 0007123 0 ustar 00 --TEST--
Check for controller return false preventing auto-renderring
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$config = array(
"application" => array(
"directory" => realpath(dirname(__FILE__)),
"dispatcher" => array(
"catchException" => 0,
"throwException" => 1,
),
"modules" => "module",
),
);
class ControllerController extends Yaf_Controller_Abstract {
public function actionAction() {
}
public function indexAction() {
$this->forward("controller", "dummy");
return FALSE; /* don't auto-render */
}
public function dummyAction() {
Yaf_Dispatcher::getInstance()->enableView();
}
}
$app = new Yaf_Application($config);
$request = new Yaf_Request_Http("/module/controller/action");
try {
$app->getDispatcher()->returnResponse(false)->dispatch($request);
} catch (Yaf_Exception $e) {
echo $e->getMessage(), "\n";
}
$view = new Yaf_View_Simple(dirname(__FILE__) . 'no-exists');
$app->getDispatcher()->setView($view);
try {
$app->getDispatcher()->returnResponse(false)->dispatch($request);
} catch (Yaf_Exception $e) {
echo $e->getMessage(), "\n";
}
$request = new Yaf_Request_Http("/module/controller/index");
try {
$app->getDispatcher()->returnResponse(false)->dispatch($request);
} catch (Yaf_Exception $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
Failed opening template %stests%cmodules%cModule%cviews%ccontroller%caction.phtml: No such file or directory
Failed opening template %stestsno-exists%ccontroller%caction.phtml: No such file or directory
Failed opening template %stestsno-exists%ccontroller%cdummy.phtml: No such file or directory
tests/101.phpt 0000644 00000001202 15173072047 0007105 0 ustar 00 --TEST--
Check for various cycle references
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
$foo = new Stdclass();
$foo->request = new Yaf_Request_Simple();
$foo->request->setParam("foo", $foo);
unset($foo);
$foo = new Stdclass();
$foo->config = new Yaf_Config_Simple(array(), 0);
$foo->config->foo = $foo;
unset($foo);
$foo = new Stdclass();
$foo->request = new Yaf_Request_Simple();
$app = new Yaf_Application(["yaf" => ["directory" => __DIR__]]);
$app->getDispatcher()->setRequest($foo->request);
unset($foo);
?>
okey
--EXPECT--
okey
tests/104.phpt 0000644 00000010551 15173072047 0007117 0 ustar 00 --TEST--
Check for Yaf_Dispatcher::dispatch() of errors while loading executor
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
yaf.use_spl_autoload=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
$app = new Yaf_Application($config);
$dispatcher = $app->getDispatcher();
$request = new Yaf_Request_Simple();
set_error_handler(function ($no, $msg) {
var_dump(substr($msg, 0, 100));
});
$request->setControllerName(str_repeat("Index", 1024 * 1024));
try {
$dispatcher->dispatch($request);
} catch (Exception $e) {
var_dump(substr($e->getMessage(), 0, 100));
}
$request->setControllerName("index");
try {
$dispatcher->dispatch($request);
} catch (Exception $e) {
var_dump($e->getMessage());
}
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", "xxx");
try {
$dispatcher->dispatch($request);
} catch (Exception $e) {
var_dump($e->getMessage());
}
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController {
public function indexAction() {
}
}
PHP
);
try {
$dispatcher->dispatch($request);
} catch (Exception $e) {
var_dump($e->getMessage());
}
$request->setControllerName("dummy");
file_put_contents(APPLICATION_PATH . "/controllers/Dummy.php", <<<PHP
<?php
class DummyController extends Yaf_Controller_Abstract {
}
PHP
);
try {
$dispatcher->dispatch($request);
} catch (Exception $e) {
var_dump($e->getMessage());
}
$request->setControllerName("dummy1");
file_put_contents(APPLICATION_PATH . "/controllers/Dummy1.php", <<<PHP
<?php
class Dummy1Controller extends Yaf_Controller_Abstract {
public \$actions;
}
PHP
);
try {
$dispatcher->dispatch($request);
} catch (Exception $e) {
var_dump($e->getMessage());
}
$request->setControllerName("dummy2");
file_put_contents(APPLICATION_PATH . "/controllers/Dummy2.php", <<<PHP
<?php
class Dummy2Controller extends Yaf_Controller_Abstract {
public \$actions = array();
}
PHP
);
try {
$dispatcher->dispatch($request);
} catch (Exception $e) {
var_dump($e->getMessage());
}
$request->setControllerName("dummy3");
file_put_contents(APPLICATION_PATH . "/controllers/Dummy3.php", <<<PHP
<?php
class Dummy3Controller extends Yaf_Controller_Abstract {
public \$actions = array("index" => NULL);
}
PHP
);
try {
$dispatcher->dispatch($request);
} catch (Exception $e) {
var_dump($e->getMessage());
}
$request->setControllerName("dummy4");
file_put_contents(APPLICATION_PATH . "/controllers/Dummy4.php", <<<PHP
<?php
class Dummy4Controller extends Yaf_Controller_Abstract {
public \$actions = array(
"index" => "actions/index.php",
"foo" => "actions/foo.php",
);
}
PHP
);
try {
$dispatcher->dispatch($request);
} catch (Exception $e) {
var_dump($e->getMessage());
}
file_put_contents(APPLICATION_PATH . "/actions/index.php", <<<PHP
<?php
class IndexAction {
}
PHP
);
try {
$dispatcher->dispatch($request);
} catch (Exception $e) {
var_dump($e->getMessage());
}
try {
$dispatcher->dispatch($request);
} catch (Exception $e) {
var_dump($e->getMessage());
}
$request->setActionName("foo");
file_put_contents(APPLICATION_PATH . "/actions/foo.php", <<<PHP
<?php
class FooAction extends Yaf_Action_Abstract {
}
PHP
);
$dispatcher->dispatch($request);
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
string(100) "path too long while loading 'Indexindexindexindexindexindexindexindexindexindexindexindexindexindexi"
string(%d) "Failed opening controller script %sIndex.php: No such file or directory"
xxxstring(%d) "Could not find class IndexController in controller script %sIndex.php"
string(73) "Controller 'IndexController' is not a subclass of Yaf_Controller_Abstract"
string(49) "There is no method indexAction in DummyController"
string(50) "There is no method indexAction in Dummy1Controller"
string(60) "There is no method indexAction in Dummy2Controller::$actions"
string(70) "Action 'index' in Dummy3Controller::actions does not have a valid path"
string(%s) "Failed opening action script %sindex.php: No such file or directory"
string(61) "Action 'IndexAction' is not a subclass of Yaf_Action_Abstract"
string(61) "Action 'IndexAction' is not a subclass of Yaf_Action_Abstract"
Fatal error: Class FooAction contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Yaf_Action_Abstract::execute) in %sfoo.php on line %d
tests/082.phpt 0000644 00000001170 15173072047 0007121 0 ustar 00 --TEST--
Check for variables out of scope
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.library="/php/global/dir"
log_errors=0
display_errors=1
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$view = new Yaf_View_Simple(DIR_ROOT);
$view->assign("name", "laruence");
$tpl = APPLICATION_PATH . '/tpls/foo.phtml';
file_put_contents($tpl, <<<HTML
<?php
echo \$name, \$tpl;
HTML
);
echo $view->render($tpl);
?>
--CLEAN--
<?php
/* unlink foo2.phtml permission denied */
require "build.inc";
shutdown();
?>
--EXPECTF--
laruence
%s: Undefined variable%stpl in %sfoo.phtml on line %d tests/064.phpt 0000644 00000002462 15173072047 0007126 0 ustar 00 --TEST--
Check for Yaf_Route_Regex with dynamic mvc
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$request = new Yaf_Request_Http("/subdir/ctl/act/name/value");
$router = new Yaf_Router();
$route = new Yaf_Route_Regex(
"#subdir/(?<c>.*?)/(.*?)/.*#",
array(
"module" => "m",
"controller" => ":c",
"action" => ":a",
),
array(
2 => "a",
)
);
$router->addRoute("subdir", $route)->addRoute("yaf", new Yaf_Route_Regex(
"#yaf/(.*?)/.*#",
array(
"action" => ':action',
"controller" => "index",
),
array(
1 => "action",
)
))->route($request);
var_dump($router->getCurrentRoute());
print_r($request->getParams());
var_dump($request->getActionName());
var_dump($request->getControllerName());
var_dump($request->getModuleName());
$request = new Yaf_Request_Http("/yaf/act/name/value");
$router->route($request);
var_dump($router->getCurrentRoute());
print_r($request->getParams());
var_dump($request->getActionName());
var_dump($request->getControllerName());
var_dump($request->getModuleName());
?>
--EXPECTF--
string(6) "subdir"
Array
(
[c] => ctl
[a] => act
)
string(3) "act"
string(3) "Ctl"
string(1) "M"
string(3) "yaf"
Array
(
[action] => act
)
string(3) "act"
string(5) "Index"
NULL
tests/032.phpt 0000644 00000001161 15173072047 0007114 0 ustar 00 --TEST--
Check for Yaf_Config_Ini with env
--SKIPIF--
<?php
if (!extension_loaded("yaf")) print "skip";
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip seems windows doesnt support this');
}
?>
--INI--
yaf.directory=/foo/bar
yaf.use_namespace=0
--FILE--
<?php
putenv("FOO=bar");
define("FOO", "Dummy");
print_r(new Yaf_Config_Ini(
dirname(__FILE__) . "/simple.ini", "envtest"));
?>
--EXPECTF--
Yaf_Config_Ini Object
(
[readonly:protected] => 1
[config:protected] => Array
(
[env] => bar
[ini] => /foo/bar
[const] => Dummy
)
[filename:protected] => %s
)
tests/069.phpt 0000644 00000001400 15173072047 0007122 0 ustar 00 --TEST--
Fixed bug that alter_response is not binary safe
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "head <?php echo chr(0);?> tail" . PHP_EOL);
$app = new Yaf_Application($config);
$app->run();
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
head tail
tests/039.phpt 0000644 00000001530 15173072047 0007123 0 ustar 00 --TEST--
Check for Yaf_View_Simple recursive render error message outputing
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.library="/php/global/dir"
log_errors=0
display_errors=1
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$view = new Yaf_View_Simple(DIR_ROOT);
$view->assign("name", "laruence");
$tpl = APPLICATION_PATH . '/tpls/foo.phtml';
$tpl2 = APPLICATION_PATH . '/tpls/foo2.phtml';
file_put_contents($tpl, <<<HTML
<?php
echo \$this->render(\$tpl);
?>
HTML
);
file_put_contents($tpl2, <<<HTML
<?php
if ((1) { //syntax error
}
?>
HTML
);
try {
echo $view->render($tpl, array('tpl' => $tpl2));
} catch (Error $e) {
echo $e->getMessage();
}
?>
--CLEAN--
<?php
/* unlink foo2.phtml permission denied */
require "build.inc";
shutdown();
?>
--EXPECTF--
syntax error, unexpected %s}%c
tests/095.phpt 0000644 00000003457 15173072047 0007137 0 ustar 00 --TEST--
Check for Yaf_Request read/write property
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.use_namespace=0
--FILE--
<?php
function ref_change(&$val) {
$val = "bad";
}
$app = new Yaf_Application(array(
"yaf" => array(
"directory" => __DIR__ ,
),
));
foreach (array(
"environ", "running", "config", "library",
"directory", "ext", "view_ext", "err_no", "err_msg",
"bootstrap", "dispatcher", 123, "noexists", ) as $k) {
print "Testing $k:\n";
var_dump($app->{$k});
$app->{$k} = true;
var_dump($app->{$k});
$app->{$k} = "inDex";
ref_change($app->{$k});
var_dump($app->{$k});
echo "\n";
}
var_dump($app);
?>
--EXPECTF--
Testing environ:
NULL
NULL
NULL
Testing running:
NULL
NULL
NULL
Testing config:
NULL
NULL
NULL
Testing library:
NULL
NULL
string(5) "inDex"
Testing directory:
string(%d) "%s"
string(%d) "%s"
string(5) "inDex"
Testing ext:
NULL
NULL
string(5) "inDex"
Testing view_ext:
NULL
NULL
string(5) "inDex"
Testing err_no:
NULL
NULL
NULL
Testing err_msg:
NULL
NULL
NULL
Testing bootstrap:
NULL
NULL
string(5) "inDex"
Testing dispatcher:
NULL
NULL
NULL
Testing 123:
NULL
NULL
NULL
Testing noexists:
NULL
NULL
NULL
object(Yaf_Application)#1 (13) {
["directory"]=>
string(5) "inDex"
["library"]=>
string(5) "inDex"
["bootstrap"]=>
string(5) "inDex"
["ext"]=>
string(5) "inDex"
["view_ext"]=>
string(5) "inDex"
["environ:protected"]=>
string(7) "product"
["running:protected"]=>
bool(false)
["err_msg:protected"]=>
NULL
["err_no:protected"]=>
int(0)
["config:protected"]=>
object(Yaf_Config_Simple)#%d (%d) {
%A
}
["dispatcher:protected"]=>
object(Yaf_Dispatcher)#%d (%d) {
%A
}
["modules:protected"]=>
array(1) {
[0]=>
string(5) "Index"
}
["default_route:protected"]=>
NULL
}
tests/070.phpt 0000644 00000001004 15173072047 0007112 0 ustar 00 --TEST--
Fixed misleading error message when providing a string in Yaf_Application construction
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$config = <<<INI
[product]
;CONSTANTS is supported
application.directory = APP_PATH "/application/"
INI;
try {
$app = new Yaf_Application($config);
$app->run();
}
catch (Exception $e){
print $e->getPrevious()->getMessage();
}
?>
--CLEAN--
--EXPECTF--
Expects a path to *.ini configuration file as parameter
tests/012.phpt 0000644 00000001434 15173072047 0007115 0 ustar 00 --TEST--
Check for Yaf_Route_Regex
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$request = new Yaf_Request_Http("/subdir/ap/1.2/name/value", "/subdir");
$router = new Yaf_Router();
$route = new Yaf_Route_regex(
"#/subdir/(.*)#",
array(
"action" => "version",
),
array(
)
);
$router->addRoute("subdir", $route)->addRoute("ap", new Yaf_Route_Regex(
"#^/ap/([^/]*)/*#i",
array(
"action" => 'ap',
),
array(
1 => 'version',
)
))->route($request);
var_dump($router->getCurrentRoute());
var_dump($request->getParam('version'));
var_dump($request->getActionName());
var_dump($request->getControllerName());
var_dump($request->getParam('name'));
?>
--EXPECTF--
string(2) "ap"
string(3) "1.2"
string(2) "ap"
NULL
NULL
tests/033.phpt 0000644 00000003242 15173072047 0007117 0 ustar 00 --TEST--
Check for Yaf_View_Simple with predefined template dir
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$config = array(
"application" => array(
"directory" => realpath(dirname(__FILE__)),
"dispatcher" => array(
"catchException" => 0,
"throwException" => 1,
),
"modules" => "module",
),
);
class ControllerController extends Yaf_Controller_Abstract {
public function actionAction() {
}
public function indexAction() {
Yaf_Dispatcher::getInstance()->disableView();
$this->forward("dummy");
}
public function dummyAction() {
Yaf_Dispatcher::getInstance()->enableView();
}
}
$app = new Yaf_Application($config);
$request = new Yaf_Request_Http("/module/controller/action");
try {
$app->getDispatcher()->returnResponse(false)->dispatch($request);
} catch (Yaf_Exception $e) {
echo $e->getMessage(), "\n";
}
$view = new Yaf_View_Simple(dirname(__FILE__) . 'no-exists');
$app->getDispatcher()->setView($view);
try {
$app->getDispatcher()->returnResponse(false)->dispatch($request);
} catch (Yaf_Exception $e) {
echo $e->getMessage(), "\n";
}
$request = new Yaf_Request_Http("/module/controller/index");
try {
$app->getDispatcher()->returnResponse(false)->dispatch($request);
} catch (Yaf_Exception $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
Failed opening template %stests%cmodules%cModule%cviews%ccontroller%caction.phtml: No such file or directory
Failed opening template %stestsno-exists%ccontroller%caction.phtml: No such file or directory
Failed opening template %stestsno-exists%ccontroller%cdummy.phtml: No such file or directory
tests/065.phpt 0000644 00000001436 15173072047 0007127 0 ustar 00 --TEST--
Yaf_Route_Regex map is optional
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$request = new Yaf_Request_Http("/subdir/ap/1.2/name/value", "/subdir");
$router = new Yaf_Router();
$router->addConfig(
array(
array(
"type" => "regex",
"match" => "#^/ap/([^/]*)/*#i",
"route" => array(
array(
"action" => 'ap',
),
),
)
)
)->route($request);
var_dump($router->getCurrentRoute());
var_dump($request->getActionName());
$router->addRoute("regex", new Yaf_Route_Regex("#^/ap/([^/]*)/*#i", array("action" => "ap")))->route($request);
var_dump($router->getCurrentRoute());
var_dump($request->getActionName());
?>
--EXPECT--
int(0)
NULL
string(5) "regex"
string(2) "ap"
tests/008.phpt 0000644 00000002766 15173072047 0007133 0 ustar 00 --TEST--
Check for Yaf_Router basic usages
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$router = new Yaf_Router();
$route = new Yaf_Route_Simple('m', 'c', 'a');
$sroute = new Yaf_Route_Supervar('r');
$router->addRoute("simple", $route)->addRoute("super", $sroute);
print_r($router);
var_dump($router->getCurrentRoute());
print_r($router->getRoutes());
print_r($router->getRoute("simple"));
var_dump($router->getRoute("noexists"));
?>
--EXPECTF--
Yaf_Router Object
(
[routes:protected] => Array
(
[_default] => Yaf_Route_Static Object
(
)
[simple] => Yaf_Route_Simple Object
(
[module:protected] => m
[controller:protected] => c
[action:protected] => a
)
[super] => Yaf_Route_Supervar Object
(
[varname:protected] => r
)
)
[current:protected] =>
)
NULL
Array
(
[_default] => Yaf_Route_Static Object
(
)
[simple] => Yaf_Route_Simple Object
(
[module:protected] => m
[controller:protected] => c
[action:protected] => a
)
[super] => Yaf_Route_Supervar Object
(
[varname:protected] => r
)
)
Yaf_Route_Simple Object
(
[module:protected] => m
[controller:protected] => c
[action:protected] => a
)
NULL
tests/multi-section.ini 0000644 00000000202 15173072047 0011203 0 ustar 00 [base ]
base.a=1
base.b=2
[ extra]
base.c=3
[ foo]
base.d=4
[ multi:: extra: base : foo ]
[ ::multi2::::: base:]
[: : :: : foo]
tests/022.phpt 0000644 00000001451 15173072047 0007115 0 ustar 00 --TEST--
Check for Yaf_Application::get/setAppDirectory
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$config = array(
"application" => array(
"directory" => realpath(dirname(__FILE__)),
"dispatcher" => array(
"catchException" => 0,
"throwException" => 0,
),
),
);
$app = new Yaf_Application($config);
var_dump($app->getAppDirectory());
$dir = $app->getAppDirectory() . "/tmp";
mkdir($dir);
$app->setAppDirectory($dir);
var_dump($app->getAppDirectory());
$app->run();
?>
--CLEAN--
<?php
rmdir(dirname(__FILE__) . "/tmp");
?>
--EXPECTF--
string(%d) "%stests"
string(%d) "%stmp"
%s fatal error: Yaf_Application::run(): Failed opening controller script %stmp%ccontrollers%cIndex.php: No such file or directory in %s022.php on line %d
tests/081.phpt 0000644 00000000542 15173072047 0007122 0 ustar 00 --TEST--
PHP7 Yaf_Response leak memory
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$response = new Yaf_Response_Cli();
$string = "Jason is a good boy";
$response->setBody($string);
$response->setBody($string);
var_dump($response->getBody());
?>
--EXPECTF--
string(19) "Jason is a good boy"
tests/067.phpt 0000644 00000002731 15173072047 0007130 0 ustar 00 --TEST--
Check actions map with defined action class
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public \$actions = array(
"sub" => "actions/sub.php",
);
public function indexAction() {
var_dump(\$this->forward('sub'));
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/actions/sub.php", <<<PHP
<?php
class SubAction extends Yaf_Action_Abstract {
public function execute() {
var_dump(\$this->getModuleName());
var_dump(\$this->getControllerName());
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "indexAction" . PHP_EOL);
file_put_contents(APPLICATION_PATH . "/views/index/sub.phtml", "subAction" . PHP_EOL);
$app = new Yaf_Application($config);
$request = new Yaf_Request_Simple();
$app->getDispatcher()->dispatch($request);
$new_request = new Yaf_Request_Simple();
$new_request->setActionName('sub');
$app->getDispatcher()->dispatch($new_request);
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
bool(true)
string(5) "Index"
string(5) "Index"
indexAction
subAction
string(5) "Index"
string(5) "Index"
subAction
tests/055.phpt 0000644 00000001075 15173072047 0007125 0 ustar 00 --TEST--
check for Yaf_Dispatcher::autoRender
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.environ="product"
yaf.use_namespace=0
--FILE--
<?php
define("APPLICATION_PATH", dirname(__FILE__));
$app = new Yaf_Application(APPLICATION_PATH . '/simple.ini');
Yaf_Dispatcher::getInstance()->autoRender(true);
var_dump(Yaf_Dispatcher::getInstance()->autoRender());
Yaf_Dispatcher::getInstance()->autoRender(false);
var_dump(Yaf_Dispatcher::getInstance()->autoRender());
?>
--EXPECTF--
bool(true)
bool(false)
tests/044.phpt 0000644 00000001012 15173072047 0007112 0 ustar 00 --TEST--
Memleaks in Yaf_Dispatcher::getInstance()
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
yaf.environ="product"
yaf.use_namespace=0
--FILE--
<?php
define("APPLICATION_PATH", dirname(__FILE__));
$app = new Yaf_Application(APPLICATION_PATH . '/simple.ini');
Yaf_Dispatcher::getInstance();
$a = Yaf_Dispatcher::getInstance();
unset($a);
Yaf_Dispatcher::getInstance();
$b = Yaf_Dispatcher::getInstance();
var_dump(get_class($b));
?>
--EXPECTF--
string(14) "Yaf_Dispatcher"
tests/issue134.phpt 0000644 00000000741 15173072050 0010165 0 ustar 00 --TEST--
ISSUE #134 (Segfault while calling assemble)
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$router = new Yaf_Router();
$route = new Yaf_Route_Rewrite(
"/detail/:id",
array(
'controller' => 'index',
'action' => 'detail',
'module' => 'kfc'
)
);
$router->addRoute("kfc/index/detail", $route);
print_r($router->getRoute('kfc/index/detail')->assemble(
array(
':id' => '1',
)
));
--EXPECTF--
/detail/1
tests/001.phpt 0000644 00000001022 15173072050 0007076 0 ustar 00 --TEST--
Check for yaf presence
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--FILE--
<?php
echo "yaf extension is available";
/*
you can add regression tests for your extension here
the output of your test code has to be equal to the
text in the --EXPECT-- section below for the tests
to pass, differences between the output and the
expected text are interpreted as failure
see php5/README.TESTING for further information on
writing regression tests
*/
?>
--EXPECT--
yaf extension is available
tests/030.phpt 0000644 00000000630 15173072050 0007104 0 ustar 00 --TEST--
Check for Yaf_Config_Ini::__construct with section
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.library="/php/global/dir"
yaf.use_namespace=0
--FILE--
<?php
$file = dirname(__FILE__) . "/simple.ini";
try {
$config = new Yaf_Config_Ini($file, "ex");
} catch (Exception $e) {
print_r($e->getMessage());
}
?>
--EXPECTF--
There is no section 'ex' in '%ssimple.ini'
tests/071.phpt 0000644 00000000426 15173072050 0007114 0 ustar 00 --TEST--
return type in Yaf_Simple_Config::valid() should be boolean
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$new = new Yaf_Config_Simple(array());
var_dump($new->valid());
?>
--CLEAN--
--EXPECTF--
bool(false)
tests/bug76217.phpt 0000644 00000002106 15173072050 0007766 0 ustar 00 --TEST--
Bug #76217 (Memory leaks with Yaf_Dispatcher::setDefault*)
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<<PHP
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract
{
public function _initView(Yaf_Dispatcher \$dispatcher)
{
\$dispatcher->setDefaultModule("index")
->setDefaultController("admin")
->setDefaultAction("login");
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/controllers/Admin.php", <<<PHP
<?php
class AdminController extends Yaf_Controller_Abstract
{
public function loginAction()
{
var_dump("index/admin/login");
return false;
}
}
PHP
);
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
"modules" => "Index,User,Admin",
),
);
$app = new Yaf_Application($config);
$app->bootstrap()->run();
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
string(%d) "%s"
tests/bug70913.phpt 0000644 00000002237 15173072050 0007770 0 ustar 00 --TEST--
Bug #70913 (Segfault while new Yaf_Controller)
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=1
yaf.lowcase_path=0
yaf.throw_exception=0
yaf.catch_exception=1
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
new SecondController(\$this->getRequest(), \$this->getResponse(), \$this->getView());
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/controllers/Second.php", <<<PHP
<?php
class SecondController extends Yaf_Controller_Abstract {
public function __construct(\$request, \$response, \$view) {}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "Okey\n");
$app = new Yaf_Application($config);
$response = $app->run();
print_r($response);
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECT--
Okey
Yaf_Response_Cli Object
(
[response_code:protected] => 0
[header_sent:protected] =>
)
tests/075.phpt 0000644 00000001602 15173072050 0007115 0 ustar 00 --TEST--
Check for Yaf_Route_Regex::assemble
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$router = new Yaf_Router();
$route = new Yaf_Route_Regex(
"#^/product/([^/]+)/([^/])+#",
array(
'controller' => "product", //route to product controller,
),
array(),
array(),
'/:m/:c/:a'
);
$router->addRoute("regex", $route);
var_dump($router->getRoute('regex')->assemble(
array(
':m' => 'module',
':c' => 'controller',
':a' => 'action'
),
array(
'tkey1' => 'tval1',
'tkey2' =>
'tval2'
)
)
);
--EXPECTF--
string(49) "/module/controller/action?tkey1=tval1&tkey2=tval2"
tests/077.phpt 0000644 00000001523 15173072050 0007121 0 ustar 00 --TEST--
Check for Yaf_Route_Static::assemble
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$router = new Yaf_Router();
$route = new Yaf_Route_Static();
$router->addRoute("static", $route);
var_dump($router->getRoute('static')->assemble(
array(
':a' => 'yafaction',
'tkey' => 'tval',
':c' => 'yafcontroller',
':m' => 'yafmodule'
),
array(
'tkey1' => 'tval1',
'tkey2' => 'tval2'
)
)
);
var_dump($router->getRoute('static')->assemble(
array(
':a' => 'yafaction',
'tkey' => 'tval',
':c' => 'yafcontroller',
':m' => 'yafmodule'
),
array(
1 => 2,
array(),
)
)
);
--EXPECTF--
string(%d) "/yafmodule/yafcontroller/yafaction?tkey1=tval1&tkey2=tval2"
string(%d) "/yafmodule/yafcontroller/yafaction"
tests/040.phpt 0000644 00000000550 15173072050 0007106 0 ustar 00 --TEST--
Fixed bug that segv in Yaf_View_Simple::render if the tpl is not a string
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.library="/php/global/dir"
yaf.use_namespace=0
--FILE--
<?php
$view = new Yaf_View_Simple(dirname(__FILE__));
$view->render(NULL);
$view->render(0);
$view->render(true);
echo "okey";
?>
--EXPECT--
okey
tests/034.phpt 0000644 00000001045 15173072050 0007111 0 ustar 00 --TEST--
Check for Yaf_View_Simple::eval
--SKIPIF--
<?php
if (!extension_loaded("yaf")) print "skip";
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip windows has a different absolute path');
}
?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$view = new Yaf_View_Simple("/tmp");
$tpl = <<<PHP
<?php
echo \$name, "\n";
foreach(\$entry as \$list) {
echo "1. ", \$list, "\n";
}
?>
<?=\$name?>
PHP;
$view->assign("entry", array('a', 'b', 'c'));
echo $view->eval($tpl, array('name' => 'template'));
?>
--EXPECTF--
template
1. a
1. b
1. c
template
tests/027.phpt 0000644 00000001601 15173072050 0007111 0 ustar 00 --TEST--
Check for Yaf autoload controller
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.library="/php/global/dir"
yaf.environ="product"
yaf.use_namespace=0
--FILE--
<?php
$config = array(
"application" => array(
"directory" => realpath(dirname(__FILE__)),
"dispatcher" => array(
"catchException" => 0,
"throwException" => 0,
),
),
);
function main() {
$dummy = new NoExistsController();
}
$app = new Yaf_Application($config);
var_dump($app->environ());
var_dump(count($app->getConfig()->application));
$app->execute("main");
$app->execute(123);
?>
--EXPECTF--
string(7) "product"
int(2)
Warning: Yaf_Loader::autoload(): Failed opening script %scontrollers%cNoExists.php: No such file or directory in %s027.php on line %d
Fatal error: Uncaught Error: Class %sNoExistsController%s not found in %s027.php:%d
%a
tests/031.phpt 0000644 00000001674 15173072050 0007116 0 ustar 00 --TEST--
Check for application.dispatcher.defaultRoute
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.library="/php/global/dir"
yaf.use_namespace=0
--FILE--
<?php
$config = array(
"application" => array(
"directory" => realpath(dirname(__FILE__)),
"dispatcher" => array(
"defaultRoute" => array(
"type" => "map",
"delimiter" => '##',
"controllerPrefer" => 1,
),
),
),
);
$app = new Yaf_Application($config);
print_r($app->getDispatcher()->getRouter()->getRoutes());
var_export($app->getDispatcher()->getRouter()->getRoutes());
?>
--EXPECTF--
Array
(
[_default] => Yaf_Route_Map Object
(
[ctl_prefer:protected] => 1
[delimiter:protected] => ##
)
)
array (
'_default' =>
%saf_Route_Map::__set_state(array(
'ctl_prefer:protected' => true,
'delimiter:protected' => '##',
)),
)
tests/020.phpt 0000644 00000001565 15173072050 0007113 0 ustar 00 --TEST--
Check for Yaf_Application errors variables
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$config = array(
"application" => array(
"directory" => realpath(dirname(__FILE__)),
"dispatcher" => array(
"catchException" => 0,
"throwException" => 0,
),
),
);
function error_handler($errno, $errstr, $errfile, $errline) {
var_dump(Yaf_Application::app()->getLastErrorNo());
var_dump(Yaf_Application::app()->getLastErrorMsg());
Yaf_Application::app()->clearLastError();
var_dump(Yaf_Application::app()->getLastErrorNo());
var_dump(Yaf_Application::app()->getLastErrorMsg());
}
$app = new Yaf_Application($config);
$app->getDispatcher()->setErrorHandler("error_handler", E_RECOVERABLE_ERROR);
$app->run();
?>
--EXPECTF--
int(516)
string(%d) "Failed opening controller script %s: %s"
int(0)
string(0) ""
tests/099.phpt 0000644 00000006213 15173072050 0007126 0 ustar 00 --TEST--
Check for Multiple exception in plugins
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
"dispatcher" => array (
"catchException" => true,
),
"library" => array(
),
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Error.php", <<<PHP
<?php
class ErrorController extends Yaf_Controller_Abstract {
public function errorAction() {
\$this->_view->msg = \$this->getRequest()->getException()->getMessage();
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<<PHP
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {
public function _initConfig(Yaf_Dispatcher \$dispatcher) {
Yaf_Registry::set("config", Yaf_Application::app()->getConfig());
}
public function _initPlugin(Yaf_Dispatcher \$dispatcher) {
\$dispatcher->registerPlugin(new TestPlugin());
}
public function _initReturn(Yaf_Dispatcher \$dispatcher) {
// \$dispatcher->returnResponse(true);
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/plugins/Test.php", <<<PHP
<?php
class TestPlugin extends Yaf_Plugin_Abstract {
public function routerStartup(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
throw new Exception("routerStartup");
}
public function routerShutdown(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
throw new Exception("routerShutdown");
}
public function dispatchLoopStartup(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
throw new Exception("dispatchLoopStartup");
}
public function preDispatch(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
throw new Exception("preDispatch");
}
public function postDispatch(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
throw new Exception("postDispatch");
}
public function dispatchLoopShutdown(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) {
throw new Exception("dispatchLoopShutdown");
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function init() {
var_dump("init");
}
public function indexAction() {
var_dump("action");
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml",
"<?php throw new Exception('view exception'); ?>");
mkdir(APPLICATION_PATH . "/views/error/");
file_put_contents(APPLICATION_PATH . "/views/error/error.phtml",
"catched: <?=\$msg?>");
$app = new Yaf_Application($config);
$app->bootstrap()->run();
?>
--CLEAN--
<?php
/* unlink foo2.phtml permission denied */
require "build.inc";
shutdown();
?>
--EXPECT--
catched: routerStartup
tests/066.phpt 0000644 00000001264 15173072050 0007121 0 ustar 00 --TEST--
Check for Yaf_Route_Regex with abnormal map
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$request = new Yaf_Request_Http("/subdir/ap/1.2/xxx/name/value", "/subdir");
$router = new Yaf_Router();
$router->addRoute("ap", new Yaf_Route_Regex(
"#^/ap/([^/]*)/([^/]*)/*#i",
array(
"action" => 'ap',
),
array(
1 => 23432,
2 => NULL,
)
))->route($request);
var_dump($router->getCurrentRoute());
var_dump($request->getParam(1));
var_dump($request->getActionName());
var_dump($request->getControllerName());
var_dump($request->getParam('name'));
?>
--EXPECTF--
string(2) "ap"
NULL
string(2) "ap"
NULL
NULL
tests/083.phpt 0000644 00000001676 15173072050 0007127 0 ustar 00 --TEST--
Check for ReturnResponse in cli
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
"view" => array(
"ext" => "html",
),
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.html", "okey");
$app = new Yaf_Application($config);
$response = $app->getDispatcher()->returnResponse(true)->dispatch(new Yaf_Request_Simple("CLI", "Index","Index","index"));
var_dump($response->getBody());
?>
--CLEAN--
<?php
/* unlink foo2.phtml permission denied */
require "build.inc";
shutdown();
?>
--EXPECTF--
string(4) "okey"
tests/issue231.phpt 0000644 00000002125 15173072050 0010161 0 ustar 00 --TEST--
ISSUE #231 (php-fpm worker core dump BUG)
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
variables_order=EPS
yaf.lowcase_path=0
yaf.throw_exception=0
yaf.catch_exception=1
yaf.use_namespace=0
--POST--
SCRIPT_FILENAME=issue231.php
--FILE--
<?php
$request = new Yaf_Request_Http(dirname(__FILE__));
print_r($request);
$request = new Yaf_Request_Http(dirname(__FILE__), dirname(dirname(__FILE__)));
var_export($request);
?>
--EXPECTF--
Yaf_Request_Http Object
(
[method] => POST
[module] =>
[controller] =>
[action] =>
[uri:protected] => %stests
[base_uri:protected] =>
[dispatched:protected] =>
[routed:protected] =>
[language:protected] =>
[params:protected] => Array
(
)
)
%saf_Request_Http::__set_state(array(
'method' => 'POST',
'module' => NULL,
'controller' => NULL,
'action' => NULL,
'uri:protected' => '%stests',
'base_uri:protected' => '%s',
'dispatched:protected' => false,
'routed:protected' => false,
'language:protected' => '',
'params:protected' =>
array (
),
))
tests/053.phpt 0000644 00000003675 15173072051 0007126 0 ustar 00 --TEST--
Check for Custom view engine
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
class SimpleView implements Yaf_View_Interface {
protected $tpl_dir;
protected $view;
public function __construct() {
$this->view = new Yaf_View_Simple(__DIR__);
}
public function assign($name, $value = NULL) {
$this->view->assign($name, $value . " custom view");
}
public function __set($name, $value = NULL) {
return $this->assign($name, $value);
}
public function getScriptPath($request = NULL) {
return $this->tpl_dir;
}
public function setScriptPath($path) {
$this->view->setScriptPath($path);
return true;
}
public function render($script, $value = NULL) {
return $this->view->render($script, $value);
}
public function display($script, $value = NULL) {
return $this->view->display($script, $value);
}
}
$tpl_dir = APPLICATION_PATH . "/views";
file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<<PHP
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {
public function _initView(Yaf_Dispatcher \$dispatcher) {
\$dispatcher->setView(new SimpleView('{$tpl_dir}'));
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
\$this->_view->assign("name", "name");
\$this->_view->val = "val";
}
}
PHP
);
file_put_contents($tpl_dir . "/index/index.phtml", <<<HTML
<?=\$name?>
<?=\$val?>
HTML
);
$app = new Yaf_Application($config);
$response = $app->bootstrap()->run();
echo $response;
?>
--CLEAN--
<?php
/* unlink foo2.phtml permission denied */
require "build.inc";
shutdown();
?>
--EXPECTF--
name custom view
val custom view
tests/078.phpt 0000644 00000002117 15173072051 0007123 0 ustar 00 --TEST--
Check for Yaf_Route_Map::assemble
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$router = new Yaf_Router();
$route = new Yaf_Route_Map();
$router->addRoute("map", $route);
var_dump($router->getRoute('map')->assemble(
array(
':c' => 'foo_bar'
),
array(
'tkey1' => 'tval1',
'tkey2' => 'tval2'
)
)
);
$route = new Yaf_Route_Map(true, '_');
$router->addRoute("map", $route);
var_dump($router->getRoute('map')->assemble(
array(
':a' => 'foo_bar'
),
array(
'tkey1' => 'tval1',
'tkey2' => 'tval2'
)
)
);
--EXPECTF--
string(%d) "/foo/bar?tkey1=tval1&tkey2=tval2"
string(%d) "/foo/bar/_/tkey1/tval1/tkey2/tval2"
tests/issue303.phpt 0000644 00000001640 15173072051 0010163 0 ustar 00 --TEST--
ISSUE #303 (local variable is overrided by view renderring)
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=0
yaf.lowcase_path=0
yaf.use_namespace=0
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
\$local = true;
\$this->display("index", array());;
var_dump(\$local);
return false;
}
}
PHP
);
file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "<?php \$local = false; ?>");
$app = new Yaf_Application($config);
$app->run();
?>
--CLEAN--
<?php
/* unlink foo2.phtml permission denied */
require "build.inc";
shutdown();
?>
--EXPECTF--
bool(true)
tests/096.phpt 0000644 00000002745 15173072051 0007132 0 ustar 00 --TEST--
Check for Custom route
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$router = new Yaf_Router();
$switch = true;
class myRoute implements Yaf_Route_Interface {
public function route($request) {
global $switch;
if ($switch) {
$request->setModuleName("moDule");
$request->setControllerName("index");
$request->action = "ActioN";
}
return $switch;
}
public function assemble($info, $verify = NULL) {
}
}
$router->addRoute("custom", new myRoute);
$request = new Yaf_Request_Http("/foo/dummy");
$router->route($request);
print_r($request);
var_dump($router->getCurrentRoute());
$switch = false;
$request = new Yaf_Request_Http("/foo/dummy");
$router->route($request);
print_r($request);
var_dump($router->getCurrentRoute());
?>
--EXPECT--
Yaf_Request_Http Object
(
[method] => CLI
[module] => Module
[controller] => Index
[action] => action
[uri:protected] => /foo/dummy
[base_uri:protected] =>
[dispatched:protected] =>
[routed:protected] => 1
[language:protected] =>
[params:protected] => Array
(
)
)
string(6) "custom"
Yaf_Request_Http Object
(
[method] => CLI
[module] =>
[controller] => Foo
[action] => dummy
[uri:protected] => /foo/dummy
[base_uri:protected] =>
[dispatched:protected] =>
[routed:protected] => 1
[language:protected] =>
[params:protected] => Array
(
)
)
string(8) "_default"
tests/045.phpt 0000644 00000002443 15173072051 0007117 0 ustar 00 --TEST--
Check for segfault while use closure as error handler
--SKIPIF--
<?php
if (!extension_loaded("yaf")) print "skip";
if (!version_compare(PHP_VERSION, "5.3", "ge")) print "skip only for 5.3+";
?>
--INI--
yaf.use_namespace=0
--FILE--
<?php
$config = array(
"application" => array(
"directory" => realpath(dirname(__FILE__)),
"dispatcher" => array(
"catchException" => 0,
"throwException" => 0,
),
),
);
class Bootstrap extends Yaf_Bootstrap_Abstract {
public function _initErrorHandler(Yaf_Dispatcher $dispatcher) {
var_dump($dispatcher->getDefaultModule());
var_dump($dispatcher->getDefaultController());
$dispatcher->setDefaultAction("dummy");
var_dump($dispatcher->getDefaultAction());
$dispatcher->setErrorHandler(function($errorCode, $errorMessage, $file, $line) {
throw new ErrorException($errorMessage, 0, $errorCode, $file, $line);
});
}
}
class IndexController extends Yaf_Controller_Abstract {
public function dummyAction() {
echo $undefined_var;
return FALSE;
}
}
$app = new Yaf_Application($config);
try {
$app->bootstrap()->run();
} catch (Exception $e) {
var_dump($e->getMessage());
}
?>
--EXPECTF--
string(5) "Index"
string(5) "Index"
string(5) "dummy"
string(33) "Undefined variable%sundefined_var"