From 84f256c2b50b6048824ea490b34c23f496dccd6c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 31 Jul 2016 17:40:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84Url=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/thinkphp/library/think/urlTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/thinkphp/library/think/urlTest.php b/tests/thinkphp/library/think/urlTest.php index 1a8e22f8..2968febd 100644 --- a/tests/thinkphp/library/think/urlTest.php +++ b/tests/thinkphp/library/think/urlTest.php @@ -30,6 +30,7 @@ class urlTest extends \PHPUnit_Framework_TestCase Route::get('blog/:id', 'index/blog'); Config::set('pathinfo_depr', '/'); Config::set('url_html_suffix', ''); + $this->assertEquals('/', Url::build('')); $this->assertEquals('/blog/thinkphp', Url::build('index/blog?name=thinkphp')); $this->assertEquals('/blog/thinkphp.html', Url::build('index/blog', 'name=thinkphp', 'html')); $this->assertEquals('/blog/10', Url::build('index/blog?id=10')); @@ -67,6 +68,13 @@ class urlTest extends \PHPUnit_Framework_TestCase $this->assertEquals('/blog/10.shtml', Url::build('/blog/10')); } + public function testBuildNameRoute() + { + Route::get(['blog', 'blog/:id'], 'index/blog'); + Config::set('url_html_suffix', 'shtml'); + $this->assertEquals('/blog/10/name/thinkphp.shtml', Url::build('blog?id=10&name=thinkphp')); + } + public function testBuildAnchor() { Route::get('blog/:id', 'index/blog'); @@ -76,4 +84,15 @@ class urlTest extends \PHPUnit_Framework_TestCase Config::set('url_common_param', true); $this->assertEquals('/blog/10.shtml?foo=bar#detail', Url::build('/blog/10#detail', "foo=bar")); } + + public function testBuildDomain() + { + Config::set('url_domain_deploy', true); + Route::domain('subdomain.thinkphp.cn', 'admin'); + $this->assertEquals('http://subdomain.thinkphp.cn/blog/10.shtml', Url::build('/blog/10')); + Route::domain('subdomain.thinkphp.cn', [ + 'hello/:name' => 'index/hello', + ]); + $this->assertEquals('http://subdomain.thinkphp.cn/hello/thinkphp.shtml', Url::build('index/hello?name=thinkphp')); + } }