forked from laruence/yaf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
036.phpt
90 lines (83 loc) · 2.46 KB
/
036.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
--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",
);
$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";
}
?>
--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=>my a=>
/my/ : m=> c=>my a=>
/my/foo : m=> c=>my a=>foo
/my//foo/ : m=> c=>my a=>foo