Skip to Main Content
PHPUnit Pocket Guide
book

PHPUnit Pocket Guide

by Sebastian Bergmann
September 2005
Intermediate to advanced content levelIntermediate to advanced
90 pages
1h 53m
English
O'Reilly Media, Inc.
Content preview from PHPUnit Pocket Guide

Chapter 13. PHPUnit and Phing

Phing (PHing Is Not GNU make) [7] is a project-build system based on Apache Ant.[8] In the context of PHP, you do not need to build and compile your sources; the intention of Phing is to ease the packaging, deployment, and testing of applications. For these tasks, Phing provides numerous out-of-the-box operation modules ("tasks") and an easy-to-use, object-oriented model for adding your own custom tasks.

Phing can be installed using the PEAR Installer, as shown in the following command line:

	pear install http://phing.info/pear/phing-2.1.0-pear.tgz

Phing uses simple XML build files that specify a target tree where various tasks are executed. One out-of-the-box task that comes with Phing is the <phpunit2> task that runs test cases using the PHPUnit framework. It is a functional port of Apache Ant's JUnit task.

Example 15 shows a Phing build.xml file that specifies a <project> named BankAccount. The project's default <target> is called test. Using the <phpunit2> task, this target runs all test cases that can be found in source files that match the *Test.php condition. This is done by using a <batchtest> element that collects the included files from any number of nested <fileset> elements. In this example, the tests declared in the class BankAccountTest in the source file BankAccountTest.php will be run.

Example 15. Phing build.xml file for the BankAccount tests

<?xml version="1.0"?> <project name="BankAccount" basedir="." default="test"> <target name="test"> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering PHP 7

Mastering PHP 7

Branko Ajzele

Publisher Resources

ISBN: 0596101031Errata Page