From ef801ec6c37fb3f2cd635b4b15b7d5ca861b330a Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 29 Feb 2016 14:24:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Route=E7=B1=BB=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E7=BB=91=E5=AE=9A=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/routeTest.php | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/thinkphp/library/think/routeTest.php b/tests/thinkphp/library/think/routeTest.php index 8fbf1298..6acb9b36 100644 --- a/tests/thinkphp/library/think/routeTest.php +++ b/tests/thinkphp/library/think/routeTest.php @@ -146,4 +146,32 @@ class routeTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(false, Route::isSsl()); } + + public function testDomain() + { + $_SERVER['HTTP_HOST'] = 'subdomain.thinkphp.cn'; + $_SERVER['REQUEST_URI'] = ''; + Route::domain('subdomain.thinkphp.cn', 'sub?abc=test&status=1'); + Route::checkDomain(); + $this->assertEquals('sub?abc=test&status=1', Route::domain('subdomain.thinkphp.cn')); + $this->assertEquals('sub', Route::bind('module')); + $this->assertEquals('test', $_GET['abc']); + $this->assertEquals(1, $_GET['status']); + + Route::domain('subdomain.thinkphp.cn', function () {return ['type' => 'module', 'module' => 'sub2'];}); + Route::checkDomain(); + $this->assertEquals('sub2', Route::bind('module')); + + Route::domain('subdomain.thinkphp.cn', '\app\index\controller'); + Route::checkDomain(); + $this->assertEquals('\app\index\controller', Route::bind('namespace')); + + Route::domain('subdomain.thinkphp.cn', '@\app\index\controller\blog'); + Route::checkDomain(); + $this->assertEquals('\app\index\controller\blog', Route::bind('class')); + + Route::domain('subdomain.thinkphp.cn', '[sub3]'); + Route::checkDomain(); + $this->assertEquals('sub3', Route::bind('group')); + } }