PHP Tutorial: PHPUnit Study Notes (i) PHPUnit Introduction and Installation

Source: Internet
Author: User
Tags pear php tutorial

PHP Tutorial: PHPUnit Study Notes (i) PHPUnit Introduction and Installation

Sin Posted in: 2011-4-9 19:15 Saturday PHP Tutorial

Recently studied and used PHPUnit in the project to do automated testing, I will be on the blog based on my PHPUnit study notes to be serialized, detailed introduction of this automated testing framework. The notes are basically based on PHPUnit's official documents and examples, with my own interpretation and matching description code. This note uses the PHPUnit version of 3.5.13, the test platform is ubuntu10.10 PHP5.3.3

What is PHPUnit?

PHPUnit is a lightweight PHP testing framework. It is a complete transplant of the JUNIT3 series version under PHP5, a member of the Xunit Test framework family (both of which are based on the design of model pioneer Kent Beck)

Installation of PHPUnit

Linux major distributions are basically with PHPUnit package, installation is very convenient, such as Ubuntu directly run the following command can be installed PHPUnit

sudo apt-get install PHPUnit

Of course, if you are a favorite geek, need other installation methods or feel that the default package is not new, then please install PHP Pear Library on your Linux, and then start installing the latest version PHPUnit from the eighth step of Windows installation below.

I would like to focus on the PHPUnit installation process under Windows, the relative linux,windows is more troublesome

1. Follow the general download PHP zip package and configure the php.ini, here is the example using C:\php-5.2.17-Win32

2. Add your PHP directory to the System environment variable path, restart the system

2. Start running input cmd and switch to your PHP directory, I am currently C:\php-5.2.17-Win32

3. Enter Go-pear.bat

First, the script will ask whether to install pear as a system-wide or local copy, here we choose the system by default, directly enter the

4. Now display the current path configuration, and ask you whether to modify, we keep the default still enter, the script will start to automatically install the Pear library after carriage return

5. When installing the script will prompt you to set php.ini inside the include_path, we follow the requirements in the php.ini inside the set, set good after the carriage return

6. The final script will remind you to import the PEAR system variable registration file, which is in your PHP directory

7. Enter the carriage, pear installation is complete, test pear is installed, you can directly enter the command line pear, if you see the following output, that is OK

8. Start installing PHPUnit, first upgrade pear, enter command

Pear Upgrade Pear

9. Then enter the following command to add Pear Channel, may be added when the network problem may be prompted to fail, try a few more times

Pear Channel-discover

Pear Channel-discover
Pear Channel-discover


If you add the following error message, please open php_openssl.dll this extension in php.ini

Unable to find the socket transport "SSL"-do you forget to enable it when do youconfigured PHP?

10. Enter the following command to start the installation of PHPUnit, similarly, the installation because of network problems may be prompted to fail, try a few more times

Pear Install--alldeps--force

Pear Install

11. After the command is finished, PHPUnit is installed, we can test whether the installation is successful by entering PHPUnit

If you enter a display that appears in PHP, then your phpunit will be installed.

PHP Tutorial: PHPUnit Study Notes (i) PHPUnit Introduction and Installation

Related Article

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: 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.