PHPUnit adalah tool untuk melakukan testing dalam melakukan development dengan Yii frameworks. PHPUnit ini memerlukan PEAR sehingga kita perlu menginstall PEAR lebih dahulu. Secara lengkap berikut langkah-langkahnya

  1. Silahkan install PHP dengan versi minimal 5.2.7 pastikan extension PEAR terpilih
  2. Silahkan masuk ke directory PHP dan jalankan: go-pear.bat seperti berikut :
    D:\php5214>go-pear.bat

    Are you installing a system-wide PEAR or a local copy?
    (system|local) [system] : local
    Please confirm local copy by typing ‘yes’ : yes

    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)                   : D:\php5214
     2. Temporary directory for processing            : D:\php5214\tmp
     3. Temporary directory for downloads             : D:\php5214\tmp
     4. Binaries directory                            : D:\php5214
     5. PHP code directory ($php_dir)                 : D:\php5214\pear
     6. Documentation directory                       : D:\php5214\docs
     7. Data directory                                : D:\php5214\data
     8. User-modifiable configuration files directory : D:\php5214\cfg
     9. Public Web Files directory                    : D:\php5214\www
    10. Tests directory                               : D:\php5214\tests
    11. Name of configuration file                    : D:\php5214\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 D:\php5214\pear.ini…
    Initialized registry…
    Preparing to install…
    installing phar://go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.3.tar…
    installing phar://go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.2.3.tar…

    installing phar://go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.9.0.tar…
    installing phar://go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.0.2.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.3
    install ok: channel://pear.php.net/Console_Getopt-1.2.3
    install ok: channel://pear.php.net/Structures_Graph-1.0.2
    install ok: channel://pear.php.net/XML_Util-1.2.1
    install ok: channel://pear.php.net/PEAR-1.9.0
    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:
    <D:\php5214\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 <D:\php5214\php.ini>? [Y/n] : y

    php.ini <D:\php5214\php.ini> include_path updated.

    Current include path           : .;C:\php5\pear
    Configured directory           : D:\php5214\pear
    Currently used php.ini (guess) : D:\php5214\php.ini
    Press Enter to continue:

    ** WARNING! Old version found at D:\php5214, please remove it or be sure to use
    the new d:\php5214\pear.bat command

    The ‘pear’ command is now at your service at d:\php5214\pear.bat
    Press any key to continue . . .

  3. Setelah itu jalankan berikut untuk menambah chanel :
    D:\php5214>pear channel-discover pear.phpunit.de
    Adding Channel “pear.phpunit.de” succeeded
    Discovery of channel “pear.phpunit.de” succeeded

    D:\php5214>pear channel-discover components.ez.no
    Adding Channel “components.ez.no” succeeded
    Discovery of channel “components.ez.no” succeeded

    D:\php5214>pear channel-discover pear.symfony-project.com
    Adding Channel “pear.symfony-project.com” succeeded
    Discovery of channel “pear.symfony-project.com” succeeded

  4. Kemudian baru install PHPUnit (http://pear.phpunit.de/)
    D:\php5214>pear install phpunit/PHPUnit-3.3.17
    Did not download optional dependencies: pear/Image_GraphViz, pear/Log, use –all
    deps 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 PHP extension “pdo”
    phpunit/PHPUnit can optionally use PHP extension “pdo_mysql”
    phpunit/PHPUnit can optionally use PHP extension “pdo_sqlite”
    phpunit/PHPUnit can optionally use PHP extension “xdebug” (version >= 2.0.0)
    downloading PHPUnit-3.3.17.tgz …
    Starting to download PHPUnit-3.3.17.tgz (272,418 bytes)
    ………………………………………done: 272,418 bytes
    install ok: channel://pear.phpunit.de/PHPUnit-3.3.17
  5. Cari file phpunit.bat dan ubah 2 baris terakhir menjadi seperti :
    set PHPBIN=”php.exe”
    “php.exe” “D:\php5214\phpunit” %*
  6. Instalasi Selenium Remote Control (Selenium RC)
    Download di http://seleniumhq.org/download/
    Extract ke directory tertentu.
    Kemudian pada directory selenium-server-1.0.x jalankan :
    java -jar selenium-server.jar

Sekarang phpunit sudah bisa dipakai.

Kunjungi www.proweb.co.id untuk menambah wawasan anda.

Instalasi PHPUnit