mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
添加Route类域名绑定测试
This commit is contained in:
@@ -146,4 +146,32 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->assertEquals(false, Route::isSsl());
|
$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'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user