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')); }
public function testDomain() { $request = Request::create('http://subdomain.thinkphp.cn'); Route::domain('subdomain.thinkphp.cn', 'sub?abc=test&status=1'); $rules = Route::rules('GET'); Route::checkDomain($request, $rules); $this->assertEquals('sub', Route::getbind('module')); $this->assertEquals('test', $_GET['abc']); $this->assertEquals(1, $_GET['status']); Route::domain('subdomain.thinkphp.cn', '\\app\\index\\controller'); $rules = Route::rules('GET'); Route::checkDomain($request, $rules); $this->assertEquals('\\app\\index\\controller', Route::getbind('namespace')); Route::domain(['subdomain.thinkphp.cn' => '@\\app\\index\\controller\\blog']); $rules = Route::rules('GET'); Route::checkDomain($request, $rules); $this->assertEquals('\\app\\index\\controller\\blog', Route::getbind('class')); }
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')); }