pear upgrade pear
查看升级后的版本
pear –V
PEAR Version: 1.9.4
PHP Version: 5.3.5
Zend Engine Version: 2.3.0
Running on: Windows NT ARTHUR-PC 6.1 build 7600 (Unknow Windows version
Ultimate Edition) i586
升级PHPUnit的版本到3.6,pear自带的版本太低了。
pear upgrade pear/PHPUnit
出现更新失败的信息
pear/PHPUnit is already installed and is the same as the released version 1.3.2
upgrade failed
先卸载当前的PHPUnit版本
pear uninstall pear/PHPUnit
注意设置自动添加频道
pear config-set auto_discover 1
添加PHPUnit的必要频道
pear channel-discover components.ez.no
pear channel-discover pear.phpunit.de
pear channel-discover pear.symfony-project.com
安装PHPUnit
pear install --alldeps phpunit/PHPUnit
查看PHPUnit的版本
phpunit –V
PHPUnit 3.6.3 by Sebastian Bergmann.
添加pear的路径到你的环境变量,例如D:xamppphp。这样能直接打pear命令了。
编写你的第一个测试
cd /d D:xampphtdocsdev142 ests
新建index.php文件
<?php//This is my first testclassMyFirstTestextendsPHPUnit_Framework_TestCase{publicfunctiontestFirst(){$stack=array();$this->assertEquals(0,count($stack));}}?>
测试你编写的代码
phpunit index.php
PHPUnit 3.6.3 by Sebastian Bergmann.
.
Time: 0 seconds, Memory: 3.50Mb
OK (1 test, 1 assertion)