Pro PHP- Patterns, Frameworks, Testing and More

(vip2019) #1

(^110) CHAPTER 8 ■ TESTING, DEPLOYMENT, AND CONTINUOUS INTEGRATION


Enabling Subversion Access


The next step is to enable Subversion access via Apache. To do this, create a virtual host on
your Apache web server (for details on creating a virtual host, see Chapter 14).
Once you have created a virtual host, simply add a <Location> tag to your configuration
file, following this format:

<Location /svn/myfirstrepo>
DAV svn
SVNPath /usr/local/svn/myfirstrepo
</Location>

You can now check out your files from other client locations using http://yoursite.com/
svn/myfirstrepo in place of file:///usr/local/svn/myfirstrepo, which works only on the
local server.

■Caution Note that the <Location> tag form shown here contains absolutely no security. Before exposing any
real code, be sure that you have proper authentication and SSL security measures in place. See Chapter 21
for SSL client certificate setup instructions.

PHPUnit for Unit Testing


PHPUnit lets you create unit tests for your application. In short, PHP unit testing involves
writing PHP scripts specifically to test other PHP scripts. This type of testing is referred to as
unit testing because the test apparatus is designed to test individual code units, like classes and
methods, one at a time. PHPUnit is an elegant solution to writing these tests, and it follows an
object-oriented development approach.

Installing PHPUnit


Installing PHPUnit is done through PEAR and is fairly straightforward. First use PEAR to “discover”
the pear.phpunit.de channel:

> pear channel-discover pear.phpunit.de
Adding Channel "pear.phpunit.de" succeeded
Discovery of channel "pear.phpunit.de" succeeded

Next, install PHPUnit and any dependencies it needs:

> pear install --alldeps phpunit/PHPUnit
downloading PHPUnit-3.1.9.tgz...
Starting to download PHPUnit-3.1.9.tgz (116,945 bytes)
.........................done: 116,945 bytes
install ok: channel://pear.phpunit.de/PHPUnit-3.1.9

Depending on your system’s PEAR layout, the PHPUnit source files should be found in
/usr/share/php/PHPUnit.

McArthur_819-9C08.fm Page 110 Friday, February 22, 2008 9:06 AM

Free download pdf