forked from laruence/yaf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
064.phpt
70 lines (63 loc) · 1.31 KB
/
064.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
--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/(.*?)/(.*?)/.*#",
array(
"module" => "m",
"controller" => ":c",
"action" => ":a",
),
array(
1 => "c",
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