Zend Studio 9.0.3 支持 phpunit

1 Zend Studio 9.0.3 本身就已經集成了PHPUNIT 3.6 和 PHPUNIT3.5 ,不過也可以用pear 的PHPUNIT ,

配置 Zend Studio 9.0.3  本身的phpunit 

點擊項目名右擊:include_path->configure include path ,添加PhpUnit 3.x Library;



  

OK

但必須注意:因爲一般做PHPUNIT 的都需要擴展Selenium,Database,Zend Studio 9.0.3  自帶的PHPUNIT 沒有這兩個擴展,如果你已經在本地安裝了pear 的phpunit 並已經擴展了Selenium,Database,可以直接把phpunit 的代碼直接拷貝到Zend Studio 9.0.3\plugins\com.zend.php.phpunit_9.0.3.201205071416\resources\library\3.6.10\PHPUnit


2 讓Zend Studio 9.0.3 支持自己的PHPUNIT ,只要把PHPUNIT 源碼include_path 進來就行(pear 的目錄導進去)

3 讓Zend Studio 9.0.3 支持thinkphp,也只要把thinphp 項目入口文件導入就行,不過需要注意,Zend Studio 9.0.3  默認php5.3

而在thinkphp 源碼(Common/runtime.php)中使用@set_magic_quotes_runtime 函數,直接在apache 中運行,不
會報錯,但是用PHPUNIT 測試時會報錯:Function set_magic_quotes_runtime() is deprecated 錯誤
解決辦法只能改源碼了

代碼:
set_magic_quotes_runtime(0);
替換爲: 
代碼:
ini_set("magic_quotes_runtime", 0);

項目配置完成後,可以進行PHPUnit的單元測試了,但是如果某次出錯之後,會在運行時不運行測試程式,直接報錯:

      “No test executed, Either a fatal error occurred, the launch was stopped manually or the script execution was halted with a ‘die’/'exit’ statement.”

      這時因爲測試出錯後,在任務管理器中就多了個 php-cgi.exe 的進程,重新執行測試文件時,如果進程中存在相同的錯誤進程,會對測試造成影響,可以將此類同名進程終止掉之後,再進行單元測試 ,以上問題就解決了



發佈了63 篇原創文章 · 獲贊 8 · 訪問量 14萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章