Yii1.1测试环境配置(一)

一.安装wampserver

    wampserver集成了PHP、Apacha、MySql,可以省去分别安装的麻烦。wampserver的安装配置方法可以自行搜索。

    wampserver安装完成后需要手动设置一下环境变量,把“F:workwampwampinphpphp5.3.10”(根据个人具体路径设置)路径加入PATH环境变量。设置好后在命令行的任意路径下输入php不报错即可。

二.安装Yii

    去官网下载Yii1.1包,将解压后的文件安装在wampserver安装路径下的www文件夹中。

    Yii安装完成后需要手动设置环境变量,把“F:workwampwampwwwyiiframework”加入PATH环境变量。

    设置好后在命令行的任意路径下输入Yiic不报错即可。

    Yii的具体使用方法请自行度娘。

三.安装PHPUnit

    根据http://www.yiibook.com/网站中《应用Yii1.1和PHP5进行敏捷Web开发》这本书中介绍的敏捷开发方法,我们需要单元测试和功能测试,PHPUnit负责单元测试。

    打开https://phpunit.de/manual/current/en/installation.html#installation.composer,按照给出的方法进行安装,具体步骤如下:

Windows系统下的安装方法:

        Globally installing the PHAR involves the same procedure as manually:    

  1.             Create a directory for PHP binaries; e.g., C:in

  2.             Append ;C:in to your PATH            environment variable            (related help)        

  3.             Download https://phar.phpunit.de/phpunit.phar and            save the file as C:inphpunit.phar

  4.             Open a command line (e.g.,            press Windows+R» type cmd» ENTER)         

  5.             Create a wrapping batch script (results in            C:inphpunit.cmd):        

    C:Usersusername> cd C:in
    C:in> echo @php "%~dp0phpunit.phar" %* > phpunit.cmd
    C:in> exit
    
  6.             Open a new command line and confirm that you can execute PHPUnit            from any path:        

    C:Usersusername> phpunit --version
    PHPUnit x.y.z by Sebastian Bergmann.
    

        For Cygwin and/or MingW32 (e.g., TortoiseGit) shell environments, you        may skip step 5. above, simply save the file as        phpunit (without .phar        extension), and make it executable via        chmod 775 phpunit.

  《应用Yii1.1和PHP5进行敏捷Web开发》书中介绍的是用pear安装,但是PHPUnit官网已经不推荐用pear安装了,所以还是按官网的方法安装。之后的使用中由于安装方法的不同会造成书中的例子跑不通,可以根据错误提示来一步步修改。

       PHPUnit安装好后还需要把phpunit.phar解压,因为之后我们需要引用其中的函数。

       运行如下两行代码:<?php                 $phar = new Phar('phpunit.phar');                 $phar=$phar->convertToExecutable(Phar::ZIP);             ?>

       可以把phar文件变成可执行的zip文件,之后解压zip文件即可得到phar文件中的具体内容。

四.selenium-remote-control-1.0.3的安装

    网上下载压缩包并解压。这个是用来功能测试用的。

    在命令行下进入服务器文件所在目录(selenium的安装目录),输入:java -jar selenium-server.jar即可运行功能测试服务器。

    什么?你没装java?好吧,请自行安装jdk,并配置环境变量。

五.总结

    至此,Yii开发的基本环境已经安装完毕,具体开发方法可参考上文中所说的参考书籍。

原文地址:https://www.cnblogs.com/lmzjh/p/4264077.html