PHPUnit PHP测试框架安装的解决办法
内容摘要
这篇文章主要为大家详细介绍了PHPUnit PHP测试框架安装的简单示例,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记!单元测试是几个现代敏捷
对此感兴趣的朋友,看看idc笔记做的技术笔记!单元测试是几个现代敏捷
文章正文
这篇文章主要为大家详细介绍了PHPUnit PHP测试框架安装的简单示例,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记!
单元测试是几个现代敏捷开发方法的基础,使得PHPUnit成为许多大型PHP项目的关键工具。这个工具也可以被Xdebug扩展用来生成代码覆盖率报告 ,并且可以与phing集成来自动测试,最后它还可以和Selenium整合来完成大型的自动化集成测试。Windows平台LAMP环境XAMPP 1.7.3下如何安装PHPUnit呢?首先,以管理员身份运行cmd,使用pear添加phpunit频道:D:\xampp\php>pear channel-discover pear.phpunit.deChannel "pear.phpunit.de" is already initialized频道添加好,尝试安装PHPUnit:D:\xampp\php>pear install phpunit/PHPUnitUnknown remote channel: pear.symfony-project.comUnknown remote channel: pear.symfony-project.comUnknown remote channel: components.ez.noUnknown remote channel: components.ez.nophpunit/PHPUnit requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0phpunit/PHPUnit requires package "channel://pear.symfony-project.com/YAML" (version >= 1.0.2)phpunit/PHPUnit can optionally use PHP extension "dbus"phpunit/DbUnit requires PEAR Installer (version >= 1.9.1), installed version is1.9.0phpunit/DbUnit requires package "channel://pear.symfony-project.com/YAML" (version >= 1.0.2)phpunit/File_Iterator requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0phpunit/PHP_CodeCoverage requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0phpunit/PHP_CodeCoverage requires package "channel://components.ez.no/ConsoleTools" (version >= 1.6)phpunit/PHP_CodeCoverage requires package "phpunit/File_Iterator" (version >= 1.2.2)phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)phpunit/PHPUnit_MockObject requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0phpunit/PHPUnit_Selenium requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0phpunit/PHP_TokenStream requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0phpunit/PHP_TokenStream requires package "channel://components.ez.no/ConsoleTools" (version >= 1.6)No valid packages foundinstall failed从提示看出,需要安装PEAR 1.9.1,而当前PEAR是1.9.0,那就要先升级PEAR版本。pear list-upgrades可以列出当前可用的更新,D:\xampp\php>pear.bat list-upgradesWARNING: channel "pear.php.net" has updated its protocols, use "pear channel-update pear.php.net" toupdateD:\xampp\php>pear channel-update pear.php.netUpdating channel "pear.php.net"Update of Channel "pear.php.net" succeededD:\xampp\php>pear.bat list-upgradesPEAR.PHP.NET AVAILABLE UPGRADES (STABLE):=========================================CHANNEL PACKAGE LOCAL REMOTE SIZEpear.php.net Archive_Tar 1.3.3 (stable) 1.3.7 (stable) 17.2kBpear.php.net Console_Getargs 1.3.4 (stable) 1.3.5 (stable) 17.8kBpear.php.net Mail 1.1.14 (stable) 1.2.0 (stable) 23kBpear.php.net Mail_Mime 1.5.2 (stable) 1.8.1 (stable) 31kBpear.php.net Mail_mimeDecode 1.5.1 (stable) 1.5.5 (stable) 11.4kBpear.php.net Net_SMTP 1.3.4 (stable) 1.4.4 (stable) 12.1kBpear.php.net Net_Socket 1.0.9 (stable) 1.0.10 (stable) 5.3kBpear.php.net PEAR 1.9.0 (stable) 1.9.1 (stable) 287kBpear.php.net Structures_Graph 1.0.3 (stable) 1.0.4 (stable) 30kBChannel pear.phpunit.de: No upgrades availableZEND.GOOGLECODE.COM/SVN AVAILABLE UPGRADES (STABLE):====================================================CHANNEL PACKAGE LOCAL REMOTE SIZEzend.googlecode.com/svn zend 1.9.6 (stable) 1.11.1 (stable) -更新所有可用更新:D:\xampp\php>pear upgrade-allWill upgrade channel://pear.php.net/archive_tarWill upgrade channel://pear.php.net/console_getargsWill upgrade channel://pear.php.net/mailWill upgrade channel://pear.php.net/mail_mimeWill upgrade channel://pear.php.net/mail_mimedecodeWill upgrade channel://pear.php.net/net_smtpWill upgrade channel://pear.php.net/net_socketWill upgrade channel://pear.php.net/pearWill upgrade channel://pear.php.net/structures_graphWill upgrade channel://zend.googlecode.com/svn/zendDid not download optional dependencies: pear/Auth_SASL, use --alldeps to download automaticallypear/Net_SMTP can optionally use package "pear/Auth_SASL"downloading Archive_Tar-1.3.7.tgz ...Starting to download Archive_Tar-1.3.7.tgz (17,610 bytes)......done: 17,610 bytesdownloading Console_Getargs-1.3.5.tgz ...Starting to download Console_Getargs-1.3.5.tgz (18,207 bytes)...done: 18,207 bytesdownloading Mail-1.2.0.tgz ...Starting to download Mail-1.2.0.tgz (23,214 bytes)...done: 23,214 bytesdownloading Mail_Mime-1.8.1.tgz ...Starting to download Mail_Mime-1.8.1.tgz (31,530 bytes)...done: 31,530 bytesdownloading Mail_mimeDecode-1.5.5.tgz ...Starting to download Mail_mimeDecode-1.5.5.tgz (11,554 bytes)...done: 11,554 bytesdownloading Net_SMTP-1.4.4.tgz ...Starting to download Net_SMTP-1.4.4.tgz (12,264 bytes)...done: 12,264 bytesdownloading Net_Socket-1.0.10.tgz ...Starting to download Net_Socket-1.0.10.tgz (5,429 bytes)...done: 5,429 bytesdownloading PEAR-1.9.1.tgz ...Starting to download PEAR-1.9.1.tgz (293,587 bytes)...done: 293,587 bytesdownloading Structures_Graph-1.0.4.tgz ...Starting to download Structures_Graph-1.0.4.tgz (30,318 bytes)...done: 30,318 bytesdownloading Zend-1.11.1.tgz ...Starting to download Zend-1.11.1.tgz (3,638,888 bytes)...done: 3,638,888 bytesupgrade-all ok: channel://pear.php.net/Archive_Tar-1.3.7upgrade-all ok: channel://pear.php.net/Console_Getargs-1.3.5upgrade-all ok: channel://pear.php.net/Mail-1.2.0upgrade-all ok: channel://pear.php.net/Mail_Mime-1.8.1upgrade-all ok: channel://pear.php.net/Net_Socket-1.0.10upgrade-all ok: channel://pear.php.net/Structures_Graph-1.0.4upgrade-all ok: channel://zend.googlecode.com/svn/Zend-1.11.1upgrade-all ok: channel://pear.php.net/Mail_mimeDecode-1.5.5upgrade-all ok: channel://pear.php.net/Net_SMTP-1.4.4upgrade-all ok: channel://pear.php.net/PEAR-1.9.1PEAR: 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"更新成功后,PEAR已经是1.9.1版了,现在可以放心地安装PHPUnit了:D:\xampp\php>pear install phpunit/PHPUnitUnknown remote channel: pear.symfony-project.comUnknown remote channel: pear.symfony-project.comUnknown remote channel: components.ez.noUnknown remote channel: components.ez.nophpunit/PHPUnit requires package "channel://pear.symfony-project.com/YAML" (version >= 1.0.2)phpunit/PHPUnit can optionally use PHP extension "dbus"phpunit/DbUnit requires package "channel://pear.symfony-project.com/YAML" (version >= 1.0.2)phpunit/PHP_CodeCoverage requires package "channel://components.ez.no/ConsoleTools" (version >= 1.6)phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)phpunit/PHP_TokenStream requires package "channel://components.ez.no/ConsoleTools" (version >= 1.6)downloading File_Iterator-1.2.3.tgz ...Starting to download File_Iterator-1.2.3.tgz (3,406 bytes)....done: 3,406 bytesdownloading PHPUnit_MockObject-1.0.3.tgz ...Starting to download PHPUnit_MockObject-1.0.3.tgz (17,333 bytes)...done: 17,333 bytesdownloading PHPUnit_Selenium-1.0.1.tgz ...Starting to download PHPUnit_Selenium-1.0.1.tgz (15,285 bytes)...done: 15,285 bytesinstall ok: channel://pear.phpunit.de/File_Iterator-1.2.3install ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.0.3install ok: channel://pear.phpunit.de/PHPUnit_Selenium-1.0.1上面信息来看,还是没有安装成功,pear.symfony-project.com和components.ez.no两个频道也要添加一下:D:\xampp\php>pear channel-discover pear.symfony-project.comAdding Channel "pear.symfony-project.com" succeededDiscovery of channel "pear.symfony-project.com" succeededD:\xampp\php>pear channel-discover components.ez.noAdding Channel "components.ez.no" succeededDiscovery of channel "components.ez.no" succeeded再次尝试安装PHPUnit:D:\xampp\php>pear install phpunit/PHPUnitphpunit/PHPUnit can optionally use PHP extension "dbus"phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)downloading PHPUnit-3.5.5.tgz ...Starting to download PHPUnit-3.5.5.tgz (116,148 bytes)....................done: 116,148 bytesdownloading DbUnit-1.0.0.tgz ...Starting to download DbUnit-1.0.0.tgz (38,183 bytes)...done: 38,183 bytesdownloading PHP_CodeCoverage-1.0.2.tgz ...Starting to download PHP_CodeCoverage-1.0.2.tgz (109,280 bytes)...done: 109,280 bytesdownloading YAML-1.0.4.tgz ...Starting to download YAML-1.0.4.tgz (9,919 bytes)...done: 9,919 bytesdownloading ConsoleTools-1.6.1.tgz ...Starting to download ConsoleTools-1.6.1.tgz (869,994 bytes)...done: 869,994 bytesdownloading PHP_TokenStream-1.0.1.tgz ...Starting to download PHP_TokenStream-1.0.1.tgz (7,250 bytes)...done: 7,250 bytesdownloading Base-1.8.tgz ...Starting to download Base-1.8.tgz (236,357 bytes)...done: 236,357 bytesinstall ok: channel://pear.symfony-project.com/YAML-1.0.4install ok: channel://components.ez.no/Base-1.8install ok: channel://pear.phpunit.de/DbUnit-1.0.0install ok: channel://components.ez.no/ConsoleTools-1.6.1install ok: channel://pear.phpunit.de/PHP_TokenStream-1.0.1install ok: channel://pear.phpunit.de/PHP_CodeCoverage-1.0.2install ok: channel://pear.phpunit.de/PHPUnit-3.5.5PHPUnit安装成功!!!注:关于PHPUnit PHP测试框架安装的简单示例的内容就先介绍到这里,更多相关文章的可以留意
代码注释