mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-09-05 14:25:31 +08:00
完善单元测试
This commit is contained in:
@@ -16,13 +16,14 @@
|
||||
|
||||
namespace tests\thinkphp\library\think;
|
||||
|
||||
use think\Lang;
|
||||
use think\Config;
|
||||
use think\Lang;
|
||||
|
||||
class langTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testSetAndGet(){
|
||||
public function testSetAndGet()
|
||||
{
|
||||
Lang::set('hello,%s', '欢迎,%s');
|
||||
$this->assertEquals('欢迎,ThinkPHP', Lang::get('hello,%s', ['ThinkPHP']));
|
||||
Lang::set('hello,%s', '歡迎,%s', 'zh-tw');
|
||||
@@ -31,16 +32,22 @@ class langTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('欢迎', Lang::get('hello'));
|
||||
$this->assertEquals('欢迎', Lang::get('HELLO'));
|
||||
$this->assertEquals('使用', Lang::get('use'));
|
||||
$this->assertEquals(['hello' => '欢迎', 'hello,%s' => '欢迎,%s', 'use' => '使用'], Lang::get());
|
||||
|
||||
Lang::set('hello,{:name}', '欢迎,{:name}');
|
||||
$this->assertEquals('欢迎,liu21st', Lang::get('hello,{:name}', ['name' => 'liu21st']));
|
||||
}
|
||||
|
||||
public function testLoad(){
|
||||
public function testLoad()
|
||||
{
|
||||
Lang::load(__DIR__ . DS . 'lang' . DS . 'lang.php');
|
||||
$this->assertEquals('加载', Lang::get('load'));
|
||||
Lang::load(__DIR__ . DS . 'lang' . DS . 'lang.php', 'test');
|
||||
$this->assertEquals('加载', Lang::get('load', [], 'test'));
|
||||
}
|
||||
|
||||
public function testDetect(){
|
||||
public function testDetect()
|
||||
{
|
||||
|
||||
Config::set('lang_list', ['zh-cn', 'zh-tw']);
|
||||
Lang::set('hello', '欢迎', 'zh-cn');
|
||||
@@ -56,9 +63,12 @@ class langTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
}
|
||||
|
||||
public function testRange(){
|
||||
public function testRange()
|
||||
{
|
||||
$this->assertEquals('zh-cn', Lang::range());
|
||||
Lang::set('hello', '欢迎', 'test');
|
||||
Lang::range('test');
|
||||
$this->assertEquals('test', Lang::range());
|
||||
$this->assertEquals('欢迎', Lang::get('hello'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,14 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
||||
Route::get('hello/:name', 'index/hello');
|
||||
Route::get(['hello/:name' => 'index/hello']);
|
||||
$this->assertEquals(['type' => 'module', 'module' => [null, 'index', 'hello']], Route::check('hello/thinkphp'));
|
||||
$this->assertEquals(['hello/:name' => ['route' => 'index/hello', 'option' => [], 'pattern' => []]], Route::getRules('GET'));
|
||||
}
|
||||
|
||||
public function testRouteMap()
|
||||
{
|
||||
Route::map('hello', 'index/hello');
|
||||
//$this->assertEquals('index/hello',Route::map('hello'));
|
||||
$this->assertEquals(['type' => 'module', 'module' => ['index', 'hello', null]], Route::check('hello'));
|
||||
}
|
||||
|
||||
public function testParseUrl()
|
||||
|
||||
Reference in New Issue
Block a user