Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Mar 14, 2020
1 parent c7d4b9e commit 618c80b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
<file name="085.phpt" role="test" />
<file name="086.phpt" role="test" />
<file name="087.phpt" role="test" />
<file name="088.phpt" role="test" />
<file name="build.inc" role="test" />
<file name="bug61493.phpt" role="test" />
<file name="bug63381.phpt" role="test" />
Expand Down
48 changes: 48 additions & 0 deletions tests/088.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--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//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//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,

0 comments on commit 618c80b

Please sign in to comment.