凌的博客

您现在的位置是: 首页 > 学无止境 > PHP > 

PHP

XamPP 安装/升级PHPUnit(一)

2015-05-08 PHP 906
PHPUnit是一个轻量级的 PHP测试框架。它是在PHP5下面对JUnit3系列版本的完整移植,是xUnit测试框架家族的一员(它们都基于模式先锋Kent Beck的设计)。 安装XAMPP,自动会安装pear和PHPUnit 但是,版本会很低,需要进
PHPUnit是一个轻量级的 PHP测试框架。它是在PHP5下面对JUnit3系列版本的完整移植,是xUnit测试框架家族的一员(它们都基于模式先锋Kent Beck的设计)。
安装XAMPP,自动会安装pear和PHPUnit 但是,版本会很低,需要进行升级,我写一下我的升级步骤。

假设我的XAMPP 安装在G盘

1.进入DOS ,进入 G/XAMPP/PHP目录(如果把 G/xampp/php添加到环境变量就不用进入指定文件夹了)。

2.升级pear

pear upgrade pear


G:\xampp\php>pear upgrade pear

WARNING: channel "pear.php.net" has updated its protocols, use "channel-update p

ear.php.net" to update

pear/Console_Getopt requires PEAR Installer (version >= 1.8.0), installed versio

n is 1.7.2

downloading PEAR-1.9.4.tgz ...

Starting to download PEAR-1.9.4.tgz (296,332 bytes)

..............................done: 296,332 bytes

downloading Archive_Tar-1.3.8.tgz ...

Starting to download Archive_Tar-1.3.8.tgz (17,995 bytes)

...done: 17,995 bytes

downloading Structures_Graph-1.0.4.tgz ...

Starting to download Structures_Graph-1.0.4.tgz (30,318 bytes)

...done: 30,318 bytes

upgrade ok: channel://pear.php.net/Archive_Tar-1.3.8

ERROR: unable to unpack C:\Users\lmm\AppData\Local\Temp\pear\download\Structures

_Graph-1.0.4.tgz

upgrade ok: channel://pear.php.net/PEAR-1.9.4

PEAR: Optional feature webinstaller available (PEAR's web-based installer)

PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)

PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)



PEAR: To install optional features use "pear install pear/PEAR#featurename"



3.查看pear版本

pear -V



G:\xampp\php>pear -V

PEAR Version: 1.9.4

PHP Version: 5.3.5

Zend Engine Version: 2.3.0

Running on: Windows NT LMM-PC 6.1 build 7601 (Unknow Windows version Home Basic

Edition Service Pack 1) i586



4.升级phpUnit发现失败。

pear upgrade pear/phpUnit

G:\xampp\php>pear upgrade pear/phpUnit

pear/phpUnit is already installed and is the same as the released version 1.3.2

upgrade failed



5.需要卸载原来的版本

pear uninstall pear/phpUnit

G:\xampp\php>pear uninstall pear/phpUnit

uninstall ok: channel://pear.php.net/PHPUnit-1.3.2



6.设置频道

pear config-set auto_discover 1

pear channel-discover components.ez.no

pear channel-discover pear.phpunit.de

pear channel-discover pear.symfony-project.com



G:\xampp\php>pear config-set auto_discover 1

config-set succeeded





G:\xampp\php>pear channel-discover components.ez.no

Adding Channel "components.ez.no" succeeded

Discovery of channel "components.ez.no" succeeded



G:\xampp\php>pear channel-discover pear.phpunit.de

Adding Channel "pear.phpunit.de" succeeded

Discovery of channel "pear.phpunit.de" succeeded



G:\xampp\php>pear channel-discover pear.symfony-project.com

Adding Channel "pear.symfony-project.com" succeeded

Discovery of channel "pear.symfony-project.com" succeeded



7.安装phpunit

pear install --alldeps phpunit/PHPUnit

G:\xampp\php>pear install --alldeps phpunit/PHPUnit

phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2

.0.5)

phpunit/PHP_Invoker requires PHP extension "pcntl"

downloading PHPUnit-3.6.10.tgz ...

Starting to download PHPUnit-3.6.10.tgz (118,595 bytes)

..........................done: 118,595 bytes

downloading File_Iterator-1.3.1.tgz ...

Starting to download File_Iterator-1.3.1.tgz (5,157 bytes)

...done: 5,157 bytes

downloading Text_Template-1.1.1.tgz ...

Starting to download Text_Template-1.1.1.tgz (3,622 bytes)

...done: 3,622 bytes

downloading PHP_CodeCoverage-1.1.1.tgz ...

Starting to download PHP_CodeCoverage-1.1.1.tgz (132,339 bytes)

...done: 132,339 bytes

downloading PHP_Timer-1.0.2.tgz ...

Starting to download PHP_Timer-1.0.2.tgz (3,686 bytes)

...done: 3,686 bytes

downloading PHPUnit_MockObject-1.1.1.tgz ...

Starting to download PHPUnit_MockObject-1.1.1.tgz (19,897 bytes)

...done: 19,897 bytes

downloading YAML-1.0.6.tgz ...

Starting to download YAML-1.0.6.tgz (10,010 bytes)

...done: 10,010 bytes

downloading PHP_TokenStream-1.1.2.tgz ...

Starting to download PHP_TokenStream-1.1.2.tgz (9,797 bytes)

...done: 9,797 bytes

install ok: channel://pear.phpunit.de/File_Iterator-1.3.1

install ok: channel://pear.phpunit.de/Text_Template-1.1.1

install ok: channel://pear.phpunit.de/PHP_Timer-1.0.2

install ok: channel://pear.symfony-project.com/YAML-1.0.6

install ok: channel://pear.phpunit.de/PHP_TokenStream-1.1.2

install ok: channel://pear.phpunit.de/PHP_CodeCoverage-1.1.1

install ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.1.1

install ok: channel://pear.phpunit.de/PHPUnit-3.6.10



8.查看phpunit版本,成功~

phpunit -V

G:\xampp\php>phpunit -V

PHPUnit 3.6.10 by Sebastian Bergmann.

unrecognized option -- V




如果出现找不到 下载地址  --需要升级一下pear


安装Pear

cmd进入PHP目录,执行go-pear安装,遇到需要输入Y的输入,其余全部回车。

关闭此控制台窗口;双击文件“PEAR_ENV.reg”,将相关信息导入注册表

安装完成。

安装PHPUnit

依次执行下面命令

1 pear channel-discover pear.phpunit.de 
2 pear channel-discover components.ez.no 
3 pear channel-discover pear.symfony-project.com 
4 pear update-channels 
5 pear upgrade-all
6 pear channel-discover pear.symfony.com 
7 pear install pear.symfony.com/Yaml
最后运行
pear install phpunit/PHPUnit或者pear install –alldeps phpunit/PHPUnit
刚开始一直安装不正确,是因为Structures_Graph放置位置有问题,在PHP目录下有PEAR/PEAR目录刚开始放到了里面的PEAR中了,就是这个原因。
 

安装的时候碰到这样一个错误:
1    No releases available for package "pear.phpunit.de/PHPUnit"
2    install failed

这个错误很有可能是本地缓存造成的,下面我们来使用
1    pear clear-cache



文章评论

0条评论