forked from love1324/php-yaf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Yaf_Route_Regex's map argument now is optional
- Loading branch information
Showing
3 changed files
with
52 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--TEST-- | ||
Yaf_Route_Regex map is optional | ||
--SKIPIF-- | ||
<?php if (!extension_loaded("yaf")) print "skip"; ?> | ||
--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" |