mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 07:02:47 +08:00
改进单元测试
This commit is contained in:
@@ -236,6 +236,9 @@ class Url
|
|||||||
{
|
{
|
||||||
foreach ($rule as $item) {
|
foreach ($rule as $item) {
|
||||||
list($url, $pattern, $domain) = $item;
|
list($url, $pattern, $domain) = $item;
|
||||||
|
if (empty($pattern)) {
|
||||||
|
return [$url, $domain];
|
||||||
|
}
|
||||||
foreach ($pattern as $key => $val) {
|
foreach ($pattern as $key => $val) {
|
||||||
if (isset($vars[$key])) {
|
if (isset($vars[$key])) {
|
||||||
$url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key . '', '<' . $key . '>'], $vars[$key], $url);
|
$url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key . '', '<' . $key . '>'], $vars[$key], $url);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class urlTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testBuildMethod()
|
public function testBuildMethod()
|
||||||
{
|
{
|
||||||
Route::get('blog/:id', '\app\index\controller\blog@read');
|
Route::get('blog/:id', '\app\index\controller\blog@read');
|
||||||
$this->assertEquals('/blog/10.html', Url::build('\app\index\controller\blog\read', 'id=10', 'html'));
|
$this->assertEquals('/blog/10.html', Url::build('[\app\index\controller\blog@read]', 'id=10', 'html'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBuildRoute()
|
public function testBuildRoute()
|
||||||
@@ -71,7 +71,7 @@ class urlTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testBuildNameRoute()
|
public function testBuildNameRoute()
|
||||||
{
|
{
|
||||||
Route::get(['name', 'blog/:id'], 'index/blog');
|
Route::get(['name', 'blog/:id'], 'index/blog');
|
||||||
$this->assertEquals(['blog/:id', ['id' => 1], null], Route::name('name'));
|
$this->assertEquals(['blog/:id', [['id' => 1], null]], Route::name('name'));
|
||||||
Config::set('url_html_suffix', 'shtml');
|
Config::set('url_html_suffix', 'shtml');
|
||||||
$this->assertEquals('/blog/10.shtml', Url::build('name?id=10'));
|
$this->assertEquals('/blog/10.shtml', Url::build('name?id=10'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user