这个问题折腾一点时间,因此吸收教训,先上一个流程图php
1.安装pear
1)在命令行中,进入php安装目录,运行:ui
go-pear.bat
(可能出现报错状况)
2)下载go-phar.bat至php安装目录,运行:this
php go-pear.phar
3)双击刚产生的PEAR_ENV.reg ,导入注册表
4)此时pear应该安装成功了,更新至最新版本:spa
pear upgrade
(这一步挺重要的,phpunit貌似是使用pear的1.9.x才能安装).net
这部分参考了 http://blog.csdn.net/calllmq/article/details/7865057命令行
二、安装phpunitblog
这部分须要注意一些东西,上面文章连接中的方法在cakephp 中不适用,按照官方手册的写法get
pear upgrade PEAR pear config-set auto_discover 1 pear install pear.phpunit.de/PHPUnit-3.7.32
使用pear 安装3.7版本,cakephp手册提示
PHPUnit 4 is not compatible with CakePHP’s Unit Testing.it
Depending on your system’s configuration, you may need to run the previous commands with sudoio
Once PHPUnit is installed with the PEAR installer, you should confirm that the PHPUnit libraries are on PHP’sinclude_path. You can do this by checking your php.ini file and making sure that the PHPUnit files are in one of theinclude_path directories.
因此不能安装4.0版本,而且须要添加include_path,我以前添加include_path 仍是失败,主要是路径的缘由
先说下include_path 做用是简化requre 的时候找到路径
引用一段博文
在php.ini文件中能够设置成 include_path = ".;C:/xampp/xampp/php/PEAR" include_path = ".;C:/Aptana Studio Workspace/jsms" 这样咱们能够在程序当中不写路径能够直接include或者require进来jsms或者PEAR文件夹下面的php文件. php代码以下 require_once('jsms_conf.php'); // jsms_conf.php 文件在 C:/Aptana Studio Workspace/jsms/下面
由于cakephp 包含的的是 PHPUnit/Autoload.php
因此include_path必须在phpunit的上一级目录下便可,例如个人PHPunit目录 C:\wamp\bin\php\php5.4.3\pear\PHPUnit 那么设置include_path include_path = ".;C:\wamp\bin\php\php5.4.3\pear"就能够了
成功以后就是这样子