So how can you ensure that the
output is always a valid one? Well, we will do that easily with unit testing later in
this chapter.
Chapter 5
[ 113 ]
Preparing for Unit Testing
To write successful unit test for PHP applications using PHPUnit, you need to
download the package, configure it, and then do some small tasks before actually
being able to execute your tests.
You can either run PHPUnit tests from the command line or from inside your script.
For now we will run our tests from within our script, but in later sections, we will
learn how to run unit tests from command line.
To start, download the package from http://www.phpunit.de and extract it in your
include path. If you are not sure what is your include path you can get that from
include_path settings in your php.ini. Or you can execute the following PHP
script to display the output:
echo get_include_path()
?>
Now extract the PHPUnit archive and place the PHPUnit folder in a folder, which
is in your include path. This PHPUnit folder contains two other folders named
. PHPUnit and PHPUnit2.
You are done as soon as you place the folders in your include path directories. Now include path directories.
Pages:
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128