Install PHPUnit in Xampp

Source: Internet
Author: User
Tags channel pear

Recently, I am preparing to develop Magento plug-ins. To ensure the code quality of the plug-ins, I decided to use TDD for development. The TDD development method seen in PHP practice suddenly feels open-minded, and it is easy to develop. Now I have the opportunity to implement it myself.

Of course, you also need to configure the PHPUnit development environment before rolling up your sleeves. The latest PHPUnit version has been migrated to your pear.phpunit.de website. This article assumes that you have configured the Xampp Development Environment

First, upgrade your pear version. The latest PHPUnit 3.6 requires a higher PEAR version. Open the CMD command line in the Start Menu.

cd /d D:\xampp\phppear config-showCONFIGURATION (CHANNEL PEAR.PHP.NET):=====================================Auto-discover new Channels     auto_discover    1Default Channel                default_channel  pear.php.netHTTP Proxy Server Address      http_proxy       <not set>PEAR server [DEPRECATED]       master_server    pear.php.netDefault Channel Mirror         preferred_mirror pear.php.netRemote Configuration File      remote_config    <not set>PEAR executables directory     bin_dir          D:\xampp\phpPEAR documentation directory   doc_dir          D:\xampp\php\docsPHP extension directory        ext_dir          D:\xampp\php\extPEAR directory                 php_dir          D:\xampp\php\pearPEAR Installer cache directory cache_dir        D:\xampp\php\tmpPEAR configuration file        cfg_dir          D:\xampp\php\cfgdirectoryPEAR data directory            data_dir         D:\xampp\php\dataPEAR Installer download        download_dir     D:\xampp\php\tmpdirectoryPHP CLI/CGI binary             php_bin          D:\xampp\php\.\php.exephp.ini location               php_ini          <not set>--program-prefix passed to     php_prefix       <not set>PHP's ./configure--program-suffix passed to     php_suffix       <not set>PHP's ./configurePEAR Installer temp directory  temp_dir         D:\xampp\php\tmpPEAR test directory            test_dir         D:\xampp\php\testsPEAR www files directory       www_dir          D:\xampp\php\wwwCache TimeToLive               cache_ttl        3600Preferred Package State        preferred_state  stableUnix file mask                 umask            0Debug Log Level                verbose          1PEAR password (for             password         <not set>maintainers)Signature Handling Program     sig_bin          c:\gnupg\gpg.exeSignature Key Directory        sig_keydir       C:\Windows\pearkeysSignature Key Id               sig_keyid        <not set>Package Signature Type         sig_type         gpgPEAR username (for             username         <not set>maintainers)User Configuration File        Filename         C:\Windows\pear.iniSystem Configuration File      Filename         C:\Windows\pearsys.ini

The above is my pear configuration file for your reference only. Enter the following command to upgrade the pear version

pear upgrade pear

View the upgraded version

pear –V
PEAR Version: 1.9.4PHP Version: 5.3.5Zend Engine Version: 2.3.0Running on: Windows NT ARTHUR-PC 6.1 build 7600 (Unknow Windows version Ultimate Edition) i586

Upgrade PHPUnit to 3.6. The pear version is too low.

pear upgrade pear/PHPUnit

Information that failed to update

pear/PHPUnit is already installed and is the same as the released version 1.3.2  upgrade failed

Uninstall the current PHPUnit version first

pear uninstall pear/PHPUnit

Note: Set auto-add Channels

pear config-set auto_discover 1
Add necessary channels for PHPUnit
pear channel-discover components.ez.no pear channel-discover pear.phpunit.depear channel-discover pear.symfony-project.com

Install PHPUnit

pear install --alldeps phpunit/PHPUnit

View PHPUnit version

phpunit –V PHPUnit 3.6.3 by Sebastian Bergmann.

Add the pear path to your environment variables, such as D: \ xampp \ php. In this way, you can directly run the pear command.

Write your first test

cd /d D:\xampp\htdocs\dev142\tests

Create an index. php file

<?php//This is my first testclass MyFirstTest extends PHPUnit_Framework_TestCase{     public function testFirst(){        $stack = array();        $this-&gt;assertEquals(0,count($stack));    }}?>

Test your code

phpunit index.phpPHPUnit 3.6.3 by Sebastian Bergmann..Time: 0 seconds, Memory: 3.50Mb OK (1 test, 1 assertion)

Reference

Http://pear.phpunit.de/

Http://amiworks.co.in/talk/installing-pear-and-phpunit-on-wamp-and-windows-7/

Https://github.com/sebastianbergmann/phpunit/

Http://blog.lixiphp.com/windows-install-pear-phpunit/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.