改进测试

This commit is contained in:
thinkphp
2016-02-28 16:14:53 +08:00
parent 5e592de087
commit ada74bcb26

View File

@@ -17,12 +17,9 @@
namespace tests\thinkphp\library\think;
use think\Hook;
class hookTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
}
public function testRun()
{
@@ -41,10 +38,11 @@ class hookTest extends \PHPUnit_Framework_TestCase
Hook::get('my_pos'));
}
public function testImport(){
public function testImport()
{
Hook::import(['my_pos' => [
'\tests\thinkphp\library\think\behavior\One',
'\tests\thinkphp\library\think\behavior\Three']
'\tests\thinkphp\library\think\behavior\Three'],
]);
$data['id'] = 0;
$data['name'] = 'thinkphp';
@@ -52,12 +50,15 @@ class hookTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(3, $data['id']);
}
public function testExec(){
public function testExec()
{
$data['id'] = 0;
$data['name'] = 'thinkphp';
$this->assertEquals(true, Hook::exec('\tests\thinkphp\library\think\behavior\One'));
$this->assertEquals(false, Hook::exec('\tests\thinkphp\library\think\behavior\One', 'test', $data));
$this->assertEquals('test', $data['name']);
$this->assertEquals('Closure', Hook::exec(function (&$data) {$data['name'] = 'Closure';return 'Closure';}));
}
}