mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 07:02:47 +08:00
增加Log类测试
This commit is contained in:
48
tests/thinkphp/library/think/logTest.php
Normal file
48
tests/thinkphp/library/think/logTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Log测试
|
||||
* @author liu21st <liu21st@gmail.com>
|
||||
*/
|
||||
namespace tests\thinkphp\library\think;
|
||||
|
||||
use think\Log;
|
||||
|
||||
class logTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testRecord(){
|
||||
Log::clear();
|
||||
Log::record('test');
|
||||
$this->assertEquals([['type'=>'log','msg'=>'test']], Log::getLog());
|
||||
Log::record('hello','info');
|
||||
$this->assertEquals([['type'=>'log','msg'=>'test'],['type'=>'info','msg'=>'hello']], Log::getLog());
|
||||
Log::clear();
|
||||
Log::info('test');
|
||||
$this->assertEquals([['type'=>'info','msg'=>'test']], Log::getLog());
|
||||
}
|
||||
|
||||
public function testSave(){
|
||||
Log::init(['type'=>'test']);
|
||||
Log::clear();
|
||||
Log::record('test');
|
||||
Log::record([1,2,3]);
|
||||
$this->assertTrue(Log::save());
|
||||
}
|
||||
|
||||
public function testWrite(){
|
||||
Log::init(['type'=>'test']);
|
||||
Log::clear();
|
||||
$this->assertTrue(Log::write('hello','info'));
|
||||
$this->assertTrue(Log::write([1,2,3],'log'));
|
||||
}
|
||||
}
|
||||
@@ -10,50 +10,55 @@
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Route测试
|
||||
* Url测试
|
||||
* @author liu21st <liu21st@gmail.com>
|
||||
*/
|
||||
|
||||
namespace tests\thinkphp\library\think;
|
||||
|
||||
use think\Url;
|
||||
use think\Route;
|
||||
use think\Config;
|
||||
use think\Route;
|
||||
use think\Url;
|
||||
|
||||
class urlTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testBuildModule(){
|
||||
|
||||
Route::get('hello/:name','index/hello');
|
||||
Route::get('hello/:id','index/hello');
|
||||
Config::set('pathinfo_depr','/');
|
||||
$this->assertEquals('/hello/thinkphp',Url::build('index/hello?name=thinkphp'));
|
||||
$this->assertEquals('/hello/thinkphp.html',Url::build('index/hello','name=thinkphp','html'));
|
||||
$this->assertEquals('/hello/10',Url::build('index/hello?id=10'));
|
||||
$this->assertEquals('/hello/10.html',Url::build('index/hello','id=10','html'));
|
||||
public function testBuildModule()
|
||||
{
|
||||
|
||||
Route::get('hello/:name', 'index/hello');
|
||||
Route::get('hello/:id', 'index/hello');
|
||||
Config::set('pathinfo_depr', '/');
|
||||
$this->assertEquals('/hello/thinkphp', Url::build('index/hello?name=thinkphp'));
|
||||
$this->assertEquals('/hello/thinkphp.html', Url::build('index/hello', 'name=thinkphp', 'html'));
|
||||
$this->assertEquals('/hello/10', Url::build('index/hello?id=10'));
|
||||
$this->assertEquals('/hello/10.html', Url::build('index/hello', 'id=10', 'html'));
|
||||
}
|
||||
|
||||
public function testBuildController(){
|
||||
Route::get('blog/:id','@index/blog/read');
|
||||
$this->assertEquals('/blog/10.html',Url::build('@index/blog/read','id=10','html'));
|
||||
public function testBuildController()
|
||||
{
|
||||
Route::get('blog/:id', '@index/blog/read');
|
||||
$this->assertEquals('/blog/10.html', Url::build('@index/blog/read', 'id=10', 'html'));
|
||||
}
|
||||
|
||||
public function testBuildMethod(){
|
||||
Route::get('blog/:id', ['\app\index\controller\blog','read']);
|
||||
$this->assertEquals('/blog/10.html',Url::build('\app\index\controller\blog\read','id=10','html'));
|
||||
public function testBuildMethod()
|
||||
{
|
||||
Route::get('blog/:id', ['\app\index\controller\blog', 'read']);
|
||||
$this->assertEquals('/blog/10.html', Url::build('\app\index\controller\blog\read', 'id=10', 'html'));
|
||||
}
|
||||
|
||||
public function testBuildRoute(){
|
||||
public function testBuildRoute()
|
||||
{
|
||||
Route::get('blog/:id', 'index/blog');
|
||||
Config::set('url_html_suffix','shtml');
|
||||
$this->assertNotEquals('/blog/10.html',Url::build('/blog/10'));
|
||||
$this->assertEquals('/blog/10.shtml',Url::build('/blog/10'));
|
||||
Config::set('url_html_suffix', 'shtml');
|
||||
$this->assertNotEquals('/blog/10.html', Url::build('/blog/10'));
|
||||
$this->assertEquals('/blog/10.shtml', Url::build('/blog/10'));
|
||||
}
|
||||
|
||||
public function testBuildAnchor(){
|
||||
public function testBuildAnchor()
|
||||
{
|
||||
Route::get('blog/:id', 'index/blog');
|
||||
Config::set('url_html_suffix','shtml');
|
||||
$this->assertEquals('/blog/10.shtml#detail',Url::build('/blog/10#detail'));
|
||||
Config::set('url_html_suffix', 'shtml');
|
||||
$this->assertEquals('/blog/10.shtml#detail', Url::build('/blog/10#detail'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user