2011年12月25日 星期日

PHPUnit 與 Selenium 整合

PHPUnit 與 selenium 整合,必須先用 pear 下載 phpunit/PHPUnit_Selenium 套件,否則無法連動。
  1. 切換到MAMP 2.0的/bin/php/php5.3.6/bin檔案夾,用pear下載 phpunit/PHPUnit_Selenium :
    cd /Applications/MAMP/bin/php/php5.3.6/bin
    sudo ./pear install phpunit/PHPUnit_Selenium
    Password:
  2. 輸入管理員密碼後,會自動安裝好 phpunit/PHPUnit_Selenium 套件:
    downloading PHPUnit_Selenium-1.1.3.tgz ...
    Starting to download PHPUnit_Selenium-1.1.3.tgz (17,425 bytes)
    ......done: 17,425 bytes
    install ok: channel://pear.phpunit.de/PHPUnit_Selenium-1.1.3
  3. http://seleniumhq.org/download/網站下載Selenium RC Server。目前是2.15.0版。解壓縮後,會得到 selenium-server-standalone-2.15.0.jar ,將檔案移到任何目錄都可以,例如 ~/Applications
  4. 打開終端機(不要用Aptana的Terminal),切換到 ~/Applications ,然後用Java執行:
    cd ~/Applications
    java -jar selenium-server-standalone-2.15.0.jar
    
  5. Selenium RC Server執行後,終端機會出現以下提示。
    2011/12/25 ?W?? 09:17:17 org.openqa.grid.selenium.GridLauncher main
    ??T: Launching a standalone server
    09:17:22.613 INFO - Java: Apple Inc. 20.4-b02-402
    09:17:22.615 INFO - OS: Mac OS X 10.7.2 x86_64
    09:17:22.626 INFO - v2.15.0, with Core v2.15.0. Built from revision 15105
    09:17:22.827 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
    09:17:22.828 INFO - Version Jetty/5.1.x
    09:17:22.828 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
    09:17:22.829 INFO - Started HttpContext[/selenium-server,/selenium-server]
    09:17:22.829 INFO - Started HttpContext[/,/]
    09:17:22.874 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@13f6ba0f
    09:17:22.875 INFO - Started HttpContext[/wd,/wd]
    09:17:22.884 INFO - Started SocketListener on 0.0.0.0:4444
    09:17:22.884 INFO - Started org.openqa.jetty.jetty.Server@4ee1d5ea
    
  6. 關閉終端機視窗就可以結束Selenium RC Server

2011年12月24日 星期六

Aptana + Yii 外加PHP Library

參考:PHP Development

Aptana + MAMP 自定伺服器

參考:Setting up an external web server to preview PHP and other non-HTML pages

2011年9月5日 星期一

RSS測試

RSS測試

2011年8月27日 星期六

Yii-1

  1. 前往MAMP網頁根目錄:
    cd /Applications/MAMP/htdocs
  2. 執行yiic腳本,產生 demo 網頁應用程式(不要用 sudo):
    ./yii//framework/yiic webapp demo
    Password:
    Create a Web application under '/Applications/MAMP/htdocs/demo'? [Yes|No] y
  3. 測試 demo :
    http://localhost/demo/index.php
  4. 執行 yiic shell , 要指定 config 檔案路徑:
    ./protected/yiic shell ./protected/config/main.php
  5. 產生 message 控制器與 helloWorld 函數:
    >> controller message helloWorld
  6. 測試 message 控制器與 helloWorld 函數:
    http://localhost/demo/index.php?r=message
    http://localhost/demo/index.php?r=message/helloWorld

2011年8月22日 星期一

MAMP 2.0 透過 pear 安裝 PHPUnit

    根據這一篇的說明:http://ericlbarnes.com/blog/post/php_pear_phpunit_mamp
    1. 刪除 MAMP 2.0.x 錯誤的設定檔:
      sudo rm /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf
    2. 前往MAMP的PEAR腳本檔案夾:
      MAMP 1.9.x:
      cd /Applications/MAMP/bin/php5.3/bin/
      
      MAMP 2.0.x:
      cd /Applications/MAMP/bin/php/php5.3.6/bin/
      
    3. 更新MAMP的PEAR:
      sudo ./pear channel-update pear.php.net
      sudo ./pear upgrade pear
    4. 檢查PEAR版本:
      ./pear -V
      PEAR Version: 1.9.4
      PHP Version: 5.3.6
    5. 安裝PHPUnit:
      sudo ./pear channel-discover pear.phpunit.de
      sudo ./pear channel-discover components.ez.no
      sudo ./pear channel-discover pear.symfony-project.com
      sudo ./pear install --alldeps phpunit/PHPUnit
    6. 檢查PEAR套件:
      ./pear list
      Installed packages, channel pear.php.net:
      =========================================
      Package          Version State
      Archive_Tar      1.3.7   stable
      Cache_Lite       1.7.12  stable
      Console_Getopt   1.3.1   stable
      PEAR             1.9.4   stable
      Structures_Graph 1.0.4   stable
      XML_Util         1.2.1   stable
    7. 製作終端機可執行的 phpunit 捷徑:
      MAMP 1.9.x
      sudo ln -s /Applications/MAMP/bin/php5.3/bin/phpunit /usr/bin/phpunit
      MAMP 2.0.x
      sudo ln -s /Applications/MAMP/bin/php/php5.3.6/bin/phpunit /usr/bin/phpunit
    8. 安裝 vfStream :
      sudo ./pear channel-discover pear.php-tools.net
      sudo ./pear install pat/vfsStream-alpha
      
    9. 測試 phpunit 捷徑:
      phpunit
      PHPUnit 3.5.15 by Sebastian Bergmann.
      
      Usage: phpunit [switches] UnitTest [UnitTest.php]
             phpunit [switches] 
      ....