Prev | Current Page 115 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

com>
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
(annotation)<#4 PHPUnit check to avoid echoing result when in test mode>
Note that we put the actual validation code into a function checkUsername() and only perform the actual
check if we are not using PHPUnit. This makes it possible to test the validation logic easily and the test case is
included in the code with this book. Although the list of existing users is an array in this example, it??™s more
likely that the script would execute a database call to check the current list of users.
To access our validation script, we need a form where the user can type in the preferred username. The
HTML is shown in listing 4.2
Listing 4.2: HTML file with simple form that requires validation
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


Simple Ajax Example

|