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"就可以了

    成功之后就是这样子

  • 相关阅读:
    网络运维基础知识手册
    运维基础1
    url protocol
    ASP.NET MVC
    关于写博客的想法
    Struts2 配置Action详解
    常用的API接口
    利用Console来学习、调试JavaScript
    JBPM4.4学习笔记
    Java设计模式之——工厂模式
  • 原文地址:https://www.cnblogs.com/linksgo2011/p/3955715.html
Copyright © 2011-2022 走看看