详解Yaf框架PHPUnit集 成测试方法
发布时间:2023-02-18 13:34:30 所属栏目:PHP教程 来源:
导读: 本文介绍了详解Yaf框架PHPUnit集成测试方法,分享给大家,具体如下:
测试目录
phpunit.xml
bootstrap.php 测试框架入口文件
TestCase.php 测试文件基础类
getApplicat
测试目录
phpunit.xml
bootstrap.php 测试框架入口文件
TestCase.php 测试文件基础类
getApplicat
本文介绍了详解Yaf框架PHPUnit集成测试方法,分享给大家,具体如下: 测试目录 phpunit.xml bootstrap.php 测试框架入口文件 TestCase.php 测试文件基础类 getApplication(); parent::setUp(); } public function testAppPath() { $this->assertEquals('/Users/xiong/Sites/kyYaf',APP_PATH); } public function testApp() { $this->assertEquals(Application::app(),self::$_application); } public function testApplication() { $this->assertNotNull(self::$_application); } public function getApplication() { if (self::$_application == null) { $this->setApplication(); } return self::$_application; } public function setApplication() { $application = new Application(APP_PATH . '/conf/application.ini'); $application->bootstrap(); self::$_application = $application; } } TokenServiceTest.php service类例子 public function testCreateToken() { $token = self::$tokenService->createToken('22'); $this->assertInternalType('array',$token); $this->assertInternalType('string',$token['token']); } } BaseControllerTest.php controller类例子 getDispatcher()->returnResponse(true)->dispatch($request); $contents = $response->getBody(); $data = json_decode($contents,true); $this->assertInternalType('array',$data); } } 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。 (编辑:云计算网_宿迁站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐