By raphael76
via codeutopia.net
Published: Aug 28 2008 / 17:11
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. For example, Zend Framework’s Zend_Test Testcase class also extends PHPUnit’s one, and you might need to extend the Zend_Test one as well… and so on. Luckily, PHPUnit has a way to add event listener that react to certain events.



Add your comment