準備作項目測試了,可是其實我並不知道怎麼作測試,雖然以前有所準備,在看php面向對象的書。但仍是雲裏霧裏的,因而開在網上找各類資料安裝phpunit 可是通常都是上來就是添加頻道的命令,真是讓人頭疼,由於我根本不清楚那是什麼意思。
概念:
「PHPUnit是一個輕量級的 PHP測試框架。它是在PHP5下面對JUnit3系列版本的完整移植,是xUnit測試框架家族的一員(它們都基於模式先鋒Kent Beck的設計)。
單元測試是幾個現代敏捷開發方法的基礎,使得PHPUnit成爲許多大型PHP項目的關鍵工具。這個工具也能夠被Xdebug擴展用來生成代碼覆蓋率報告 ,而且能夠與phing集成來自動測試,最後它還能夠和Selenium整合來完成大型的自動化集成測試。」
其實這段我也不明白說什麼呢。
在找資料的過程當中我發現好多方法都是各類轉載來的,能用不能用還兩說真是讓人頭痛。索性我本身測試好了方上來。
個人環境
appserv 5.2.6
框架 ci(CodeIgniter)
zend studio 8.01
下面是zend 激活碼
zend studio 8 註冊碼(適用於7.0以上全部版本)
Username: zendstudio.net
Serial Number: 3727234F6095F72034F6095F
下面是我操做記錄 能夠看出來各類錯誤的地方。
關鍵代碼 就兩行 一個是安裝,一個是註冊,最後是添加頻道的命令。
cmd 裏 php
F:\>cd AppServ F:\AppServ>dir 驅動器 F 中的卷是 WORKSTATION 卷的序列號是 C352-49C7 F:\AppServ 的目錄 2012/11/24 20:15 <DIR> . 2012/11/24 20:15 <DIR> .. 2012/12/17 22:08 <DIR> www 2012/11/24 20:15 <DIR> Apache2.2 2012/11/24 20:15 <DIR> php5 2012/11/24 20:15 <DIR> MySQL 2012/11/24 20:15 119,214 Uninstall-AppServ2.5.10.exe 1 個文件 119,214 字節 6 個目錄 200,772,681,728 可用字節 F:\AppServ\php5>go-pear.bat //安裝 F:\AppServ\php5>pear version PEAR Version: 1.9.4 PHP //版本 Version: 5.2.6 Zend Engine Version: 2.2.0 F:\AppServ\php5>PEAR_ENV.reg //註冊 F:\AppServ\php5>pear channel-discover pear.phpunit.de //添加頻道 Adding Channel "pear.phpunit.de" succeeded Discovery of channel "pear.phpunit.de" succeeded F:\AppServ\php5>pear channel-discover components.ez.no Adding Channel "components.ez.no" succeeded Discovery of channel "components.ez.no" succeeded F:\AppServ\php5>pear channel-discover pear.symfony-project.com pear install phpu nit/PHPUnit-3.5.5 No channel server specified
php pear安裝 F:\>cd AppServ F:\AppServ>dir 驅動器 F 中的卷是 WORKSTATION 卷的序列號是 C352-49C7 F:\AppServ 的目錄下的文件 www /Apache2.2 / php5 / MySQL/ Uninstall-AppServ2.5.10.exe F:\AppServ>cd php5 F:\AppServ\php5>dir 驅動器 F 中的卷是 WORKSTATION 卷的序列號是 C352-49C7 F:\AppServ\php5 的目錄 //主要執行的是這個文件 2013/01/14 15:53 3,681,106 go-pear.phar /** *這裏是錯誤的操做,由於在pear文件夾裏有一個文件覺得用php去執行就能夠了 * ***/ F:\AppServ\php5>php PEAR/go-pear.bat Could not open input file: PEAR/go-pear.bat //這句也是在網上看到的可能在其餘環境下能夠吧。 F:\AppServ\php5>php -d phar.require_hash=0 PEAR/go-pear.bat Could not open input file: PEAR/go-pear.bat F:\AppServ\php5> pear channel-discover pear.phpunit.de 'pear' 不是內部或外部命令,也不是可運行的程序 或批處理文件。 F:\AppServ\php5>pear channel-discover pear.phpunit.de 'pear' 不是內部或外部命令,也不是可運行的程序 或批處理文件。 F:\AppServ\php5>php -d phar.require_hash=0 PEAR/go-pear.bat Could not open input file: PEAR/go-pear.bat F:\AppServ\php5>php PEAR/go-pear.bat Could not open input file: PEAR/go-pear.bat /**這裏是錯誤的操做***/ //這裏是正確的 F:\AppServ\php5>go-pear.bat Are you installing a system-wide PEAR or a local copy? (system|local) [system] : Below is a suggested file layout for your new PEAR installation. To change individual locations, type the number in front of the directory. Type 'all' to change all of them or simply press Enter to accept these locations. 1. Installation base ($prefix) : F:\AppServ\php5 2. Temporary directory for processing : F:\AppServ\php5\tmp 3. Temporary directory for downloads : F:\AppServ\php5\tmp 4. Binaries directory : F:\AppServ\php5 5. PHP code directory ($php_dir) : F:\AppServ\php5\pear 6. Documentation directory : F:\AppServ\php5\docs 7. Data directory : F:\AppServ\php5\data 8. User-modifiable configuration files directory : F:\AppServ\php5\cfg 9. Public Web Files directory : F:\AppServ\php5\www 10. Tests directory : F:\AppServ\php5\tests 11. Name of configuration file : C:\Windows\pear.ini 12. Path to CLI php.exe : . 1-12, 'all' or Enter to continue: *WARNING* We found php.exe under ., it uses an unknown SAPI. PEAR commandline tool has not been tested with it, if you have a CLI (or CGI) php.exe available, we strongly recommend using it. Beginning install... Configuration written to C:\Windows\pear.ini... Initialized registry... Preparing to install... installing phar://go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.7.tar... installing phar://go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.3.0.tar... installing phar://go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.9.4.tar... installing phar://go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.0.4.tar. .. installing phar://go-pear.phar/PEAR/go-pear-tarballs/XML_Util-1.2.1.tar... install ok: channel://pear.php.net/Archive_Tar-1.3.7 install ok: channel://pear.php.net/Console_Getopt-1.3.0 install ok: channel://pear.php.net/Structures_Graph-1.0.4 install ok: channel://pear.php.net/XML_Util-1.2.1 install 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" ****************************************************************************** WARNING! The include_path defined in the currently used php.ini does not contain the PEAR PHP directory you just specified: <F:\AppServ\php5\pear> If the specified directory is also not in the include_path used by your scripts, you will have problems getting any PEAR packages working. Would you like to alter php.ini <C:\Windows\php.ini>? [Y/n] : y php.ini <C:\Windows\php.ini> include_path updated. Current include path : .;C:\php5\pear Configured directory : F:\AppServ\php5\pear Currently used php.ini (guess) : C:\Windows\php.ini Press Enter to continue: ** WARNING! Old version found at F:\AppServ\php5, please remove it or be sure to use the new f:\appserv\php5\pear.bat command The 'pear' command is now at your service at f:\appserv\php5\pear.bat * WINDOWS ENVIRONMENT VARIABLES * For convenience, a REG file is available under F:\AppServ\php5PEAR_ENV.reg . This file creates ENV variables for the current user. Double-click this file to add it to the current user registry. 請按任意鍵繼續. . . //其實雙擊這個文件就能夠了 F:\AppServ\php5>pera_evn.reg 'pera_evn.reg' 不是內部或外部命令,也不是可運行的程序 或批處理文件。 F:\AppServ\php5>pear version PEAR Version: 1.9.4 PHP Version: 5.2.6 Zend Engine Version: 2.2.0 Running on: Windows NT CHAO 6.2 build 9200 F:\AppServ\php5>pear channel-discover pear.phpunit.de Adding Channel "pear.phpunit.de" succeeded Discovery of channel "pear.phpunit.de" succeeded F:\AppServ\php5>pear channel-discover components.ez.no Adding Channel "components.ez.no" succeeded Discovery of channel "components.ez.no" succeeded F:\AppServ\php5>pear channel-discover pear.symfony-project.com pear install phpu nit/PHPUnit-3.5.5 No channel server specified F:\AppServ\php5> F:\AppServ\php5>pear version PEAR Version: 1.9.4 PHP Version: 5.2.6 Zend Engine Version: 2.2.0 Running on: Windows NT CHAO 6.2 build 9200 F:\AppServ\php5>PEAR_ENV.reg F:\AppServ\php5>pear channel-discover pear.symfony-project.com pear install phpu nit/PHPUnit-3.5.5 No channel server specified F:\AppServ\php5>pear channel-discover pear.phpunit.de Channel "pear.phpunit.de" is already initialized F:\AppServ\php5> F:\AppServ\php5>pear channel-discover pear.symfony-project.com Adding Channel "pear.symfony-project.com" succeeded Discovery of channel "pear.symfony-project.com" succeeded F:\AppServ\php5>pear install phpunit/PHPUnit Did not download optional dependencies: pear/Image_GraphViz, pear/Log, symfony/Y AML, use --alldeps to download automatically phpunit/PHPUnit can optionally use package "pear/Image_GraphViz" (version >= 1.2 .1) phpunit/PHPUnit can optionally use package "pear/Log" phpunit/PHPUnit can optionally use package "symfony/YAML" (version >= 1.0.2) phpunit/PHPUnit can optionally use PHP extension "xdebug" (version >= 2.0.5) downloading PHPUnit-3.4.15.tgz ... Starting to download PHPUnit-3.4.15.tgz (255,036 bytes) .....................................................done: 255,036 bytes install ok: channel://pear.phpunit.de/PHPUnit-3.4.15 F:\AppServ\php5>phpunit --version PHPUnit 3.4.15 by Sebastian Bergmann.
go-pear.bat 裏存儲着 @ECHO OFF set PHP_BIN=php.exe %PHP_BIN% -d output_buffering=0 PEAR\go-pear.phar %PHP_BIN% -d phar.require_hash=0 PEAR\go-pear.phar pause 好像是設置用哪一個程序來處理go-pear.pahr的 聽說會報錯: 「……~/Zend/ZendServer/bin/PEAR/go-pear.phar does not have a signature」 經過查找資料,修改 go-pear.bat 的第三條語句 %PHP_BIN% -d output_buffering=0 PEAR/go-pear.phar,爲 %PHP_BIN% -d phar.require_hash=0 PEAR/go-pear.phar 纔會開始安裝 PEAR。 修改後的 go-pear.bat 文件內容: @ECHO OFF set PHP_BIN=php.exe rem %PHP_BIN% -d output_buffering=0 PEAR/go-pear.phar %PHP_BIN% -d phar.require_hash=0 PEAR/go-pear.phar pause
我打算安裝更高版本的進行測試。
個人這個也不很詳細,也不仔細。(但願你們多多拍磚,謝謝!)下面是各家的參考,貌似不是複製粘貼的質量還能夠,同時也是我學習的榜樣。 web
(
http://be-evil.org/?keyword=unit&page=2
http://www.jb51.net/article/27194.htm
http://blog.csdn.net/zhangking/article/details/5712794
http://blog.lixiphp.com/windows-install-pear-phpunit/
http://www.jb51.net/article/27194.htm
)
windows
小總結: app
不少時候實際上是本身不夠耐心的學習觀察才形成錯誤,同時不可以常常的反思和總結而常常犯一樣的錯誤。 框架
還有就是拿過就轉用完就扔真不是什麼好習慣。 ide
這篇文章若是有時間我還會再次完善的。 工具