Identity and Access Management Consultant
IT Search
US-TX-Dallas

Justtechjobs.com Post A Job | Post A Resume

Debugging PHP
Introduction
The debugging process is a time consuming activity. When the project is a small group of scripts all is easy, but when the size and complexity of the project grows, the debugging time increases dramatically. With PhpUnit you can speed up your debugging process.
PhpUnit is a PHP port of JUnit test framework wrote by Fred Yankowski , you can download it from http://www.ontosys.com/phiki/PhpUnit. With PhpUnit you can write a suite of tests to check the correctness of your code like a security harness. After the creation of the test suite you can run all the tests automatically in a single step.
When you detect a bug, you can write a test to catch it. If the same bug is introduced again you will detect it as soon as you run your test suite. If you run the test suite frequently your will increase the robustness of your code.
Getting started
Suppose we want to write a test suite for our simple Account class.

<?php

class Account{
  var
$balance;

  function
Account($initialBalance=0){
    
$this->balance = $initialBalance;
  }
  
  function
withdraw($amount){
    
$this->balance -= $amount;
  }
  
  function
deposit($amount){
    
$this->balance += $amount;
  }
  
  function
getBalance(){
    return
$this->balance;
  }

  function
transferFrom(&$sourceAccount,$amount){
    
$sourceAccount->withdraw($amount);
    
$this->deposit($amount);
  }
?>
[ Next Page ]


Comments:
Problem with PhpUnitShaji Mathew02/15/02 06:59
"enhanced" phpunitAdrian Kubala07/18/01 11:07
RE: What if I don't know the result?Oier Blasco06/13/01 01:50
What about the Zend de buggerMooza05/25/01 13:04
What if I don't know the result?Ken Egervari04/12/01 06:03
This WILL save you time and heartacheAdam Jeffery04/11/01 12:28
PhpUnit.sourceforge.net now hosts PhpUnit codFred Yankowski04/10/01 10:37
see PhpUnit.sourceforge.netFred Yankowski04/09/01 19:31
download of class TestCaseDaniel Hopp04/09/01 09:42
followed the link but no joyDarren Christie04/09/01 04:02
This type of development is worth the time.Robert Nickens04/07/01 11:04
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.