1 Zend Studio 9.0.3 本身就已经集成了PHPUNIT 3.6 和 PHPUNIT3.5 ,不过也可以用pear 的PHPUNIT ,
配置 Zend Studio 9.0.3 本身的phpunit
点击项目名右击:include_path->configure include path ,添加PhpUnit 3.x Library;
OK
但必须注意:因为一般做PHPUNIT 的都需要扩展Selenium,Database,Zend Studio 9.0.3 自带的PHPUNIT 没有这两个扩展,如果你已经在本地安装了pear 的phpunit 并已经扩展了Selenium,Database,可以直接把phpunit 的代码直接拷贝到Zend Studio 9.0.3\plugins\com.zend.php.phpunit_9.0.3.201205071416\resources\library\3.6.10\PHPUnit
2 让Zend Studio 9.0.3 支持自己的PHPUNIT ,只要把PHPUNIT 源码include_path 进来就行(pear 的目录导进去)
3 让Zend Studio 9.0.3 支持thinkphp,也只要把thinphp 项目入口文件导入就行,不过需要注意,Zend Studio 9.0.3 默认php5.3
而在thinkphp 源码(Common/runtime.php)中使用@set_magic_quotes_runtime 函数,直接在apache 中运行,不
会报错,但是用PHPUNIT 测试时会报错:Function set_magic_quotes_runtime() is deprecated 错误
解决办法只能改源码了
代码:
set_magic_quotes_runtime(0);
替换为:
代码:
ini_set("magic_quotes_runtime", 0);
4 项目配置完成后,可以进行PHPUnit的单元测试了,但是如果某次出错之后,会在运行时不运行测试程式,直接报错:
“No test executed, Either a fatal error occurred, the launch was stopped manually or the script execution was halted with a ‘die’/'exit’ statement.”
这时因为测试出错后,在任务管理器中就多了个 php-cgi.exe 的进程,重新执行测试文件时,如果进程中存在相同的错误进程,会对测试造成影响,可以将此类同名进程终止掉之后,再进行单元测试 ,以上问题就解决了