Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

CodeUtopia Blog:
Database helper for PHPUnit
Aug 28, 2008 @ 15:22:12

On the CodeUtopia blog there's a recent post with info on creating a custom event listener in PHPUnit that can help keep you database data completely clean.

When testing code which uses the database, you would usually want to make sure the database stays pristine for each test - All tables should be empty, as any extra data could interfere with the tests. You could probably write an extended Testcase class which automatically does this before each test in setUp and afterwards in tearDown, but it may have some issues. [...] Luckily, PHPUnit has a way to add event listener that react to certain events.

It uses the TestListener interface to make the event handler that (with the help of Doctrine) starts up, makes the tables with data and wipes them out at the end.

Code for the sample listener is in the post and included is the method for checking to see if you even need to use the database or not.

tagged: database phpunit event listener database testlistener

Link:

Sebastian Bergman's Blog:
PHPUnit Support in PHPEclipse
Mar 17, 2006 @ 13:09:46

On his blog, Sebastian Bergmann has a quick post about the PHPUnit support that he's been shown in an upcoming patch to the PHPEclipse project.

Steven Balthazor sent me a first version of his PHPUnit integration for PHPEclipse today.

The PHPUnit part of this (a TestListener that communicates via a socket with Eclipse) has been committed to CVS. Stephen will make his plugin code available shortly.

You can grab the update to your PHPUnit install from that CVS location, but keep an eye out for the patch to make its way out - they're both required to get it working.

tagged: phpunit suppot phpeclipse patch cvs update testlistener phpunit suppot phpeclipse patch cvs update testlistener

Link:

Sebastian Bergman's Blog:
PHPUnit Support in PHPEclipse
Mar 17, 2006 @ 13:09:46

On his blog, Sebastian Bergmann has a quick post about the PHPUnit support that he's been shown in an upcoming patch to the PHPEclipse project.

Steven Balthazor sent me a first version of his PHPUnit integration for PHPEclipse today.

The PHPUnit part of this (a TestListener that communicates via a socket with Eclipse) has been committed to CVS. Stephen will make his plugin code available shortly.

You can grab the update to your PHPUnit install from that CVS location, but keep an eye out for the patch to make its way out - they're both required to get it working.

tagged: phpunit suppot phpeclipse patch cvs update testlistener phpunit suppot phpeclipse patch cvs update testlistener

Link:


Trending Topics: