@ECHO OFF
set PHP_BIN=php.exe
%PHP_BIN% -d phar.require_hash=0 PEAR\go-pear.phar
pause
以下内容于2012-09-07更新
步骤:
到 http://windows.php.net/downloads/releases/archives/ 下载PHP,解压并重命名到为php5.x.x,进入C:\Program Files\PHP5.x.x目录
如果需要扩展,打开php.ini,设置 extension_dir = "ext" , 取消对应扩展的注释
打开cmd,进入C:\Program Files\PHP5.x.x目录,运行go-pear
提示
Are you installing a system-wide PEAR or a local copy? (system|local) [system]
按回车确定
提示
1. Installation base ($prefix) : D:\path_to_your_php\php5.x.x
<?php
class ArrayTest extends PHPUnit_Framework_TestCase
{
public function testNewArrayIsEmpty()
{
// Create the Array fixture.
$fixture = Array();
// Assert that the size of the Array fixture is 0.
$this->assertEquals(0, sizeof($fixture));
}
public function testArrayContainsAnElement()
{
// Create the Array fixture.
$fixture = Array();
// Add an element to the Array fixture.
$fixture[] = 'Element';
// Assert that the size of the Array fixture is 1.
$this->assertEquals(1, sizeof($fixture));
}
}
?>
然后在命令行下运行:phpunit ArrayTest,就可以看到相应的结果了。
不过在命令行下敲字母总是让人不爽的,我们可以让这个过程更有趣一些,以EditPlus编辑器为例:
Tools -> Configure User Tools -> Add Tool
然后设定:
Menu Text : PHPUnit
Command : C:\Program Files\PHP5.x.x\phpunit.bat
Argument : $(FileNameNoExt)
InitialDirecotry : $(FileDir)
搞定了,如果这是你的EditPlus中第一个UserTool的话,那么当你编辑好你的Test类文件后,只要按下Ctrl + 1就可以调出相应的命令行运行界面了。