修正异常处理和单元测试

This commit is contained in:
yunwuxin
2016-05-15 10:14:17 +08:00
parent 00b17411b6
commit f78ba76767
6 changed files with 36 additions and 48 deletions

View File

@@ -18,6 +18,7 @@ namespace tests\thinkphp\library\think;
use ReflectionMethod;
use think\Exception as ThinkException;
use think\exception\HttpException;
class MyException extends ThinkException
{
@@ -29,9 +30,9 @@ class exceptionTest extends \PHPUnit_Framework_TestCase
public function testGetHttpStatus()
{
try {
throw new ThinkException("Error Processing Request", 1);
} catch (ThinkException $e) {
$this->assertEquals(500, $e->getHttpStatus());
throw new HttpException(404, "Error Processing Request");
} catch (HttpException $e) {
$this->assertEquals(404, $e->getStatusCode());
}
}