zoukankan      html  css  js  c++  java
  • 在cakephp中使用 phpunit

    这个问题折腾一点时间,所以吸取教训,先上一个流程图

    1.安装pear
    1)在命令行中,进入php安装目录,运行:

    go-pear.bat

    (可能出现报错情况)
    2)下载go-phar.bat至php安装目录,运行:

    php go-pear.phar

    3)双击刚产生的PEAR_ENV.reg ,导入注册表
    4)此时pear应该安装成功了,更新至最新版本:

    pear upgrade

    (这一步挺重要的,phpunit貌似是使用pear的1.9.x才能安装)

    这部分参考了 http://blog.csdn.net/calllmq/article/details/7865057

    2、安装phpunit

    这部分需要注意一些东西,上面文章链接中的方法在cakephp 中不适用,按照官方手册的写法

    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.

    Depending on your system’s configuration, you may need to run the previous commands with sudo

    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:wampinphpphp5.4.3pearPHPUnit 那么设置include_path  include_path = ".;C:wampinphpphp5.4.3pear"就可以了

    成功之后就是这样子

  • 相关阅读:
    java学习(一)
    linux下java环境配置
    移动平台开发团队展示
    VS的安装项目:解决安装后注册表中程序信息InstallLocation为空的问题
    .NET将数据导出到Excel表(如何指定默认文件名)
    Linux Shell编程入门
    http与WebSocket
    git push时报错filename too long的解决
    js中传统事件绑定模拟现代事件处理
    对三次握手的理解
  • 原文地址:https://www.cnblogs.com/linksgo2011/p/3955715.html
Copyright © 2011-2022 走看看