예제 #1
0
 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'));
 }