 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
CodeUtopia Blog: Database helper for PHPUnit
by Chris Cornutt August 28, 2008 @ 10: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.
voice your opinion now!
database phpunit event listener database testlistener
Maarten Manders' Blog: Static + Unit Tests = Arrrghhh!
by Chris Cornutt August 08, 2008 @ 10:23:08
Take a hint from Maarten Manders when renaming and moving around your unit testing order:
It's absolutely amazing how much you can mess up unit tests just by changing their order! (Trevi_* comes after Tilllate_*) Everyone knows that tests are supposed to be independent. But we all know how it is.
He asks for recommendations on what to do to help the situation. Comments on the post (including ones from Lukas Smith and Sebastian Bergmann) mention using PHPT, a new version of PHPUnit that will do just what he wants and whether or not to use Singletons.
voice your opinion now!
unittest static phpt phpunit recommend
Raphael Stolt's Blog: Creating custom PHPUnit assertions
by Chris Cornutt July 29, 2008 @ 10:25:15
Raphael Stolt has written up a post for his blog talking about custom PHPUnit assertions and a simple method to create them.
In this blog post I'd like to set the focus on some of the aspects of the Custom Assertion pattern, by showing how to create custom PHPUnit assertions, which attacks the above mentioned smell [of bad test code] and its retroactive effects with a huge antiperspirant flagon, while also providing the chance to build a customer friendly and domain related test vocabulary.
His first assertion is simple, checking the contents of a bag object to be sure that there are no duplicate items and that its content count is reduced by one if something is removed. Then, he moves on to making the custom assertion for his "IdShouldFollowAgreedConvention" test. He explains how to use the assertion class and how it all fits together in the final, functional test case.
voice your opinion now!
custom phpunit assertion unittest customassertion pattern
Matthew Weier O'Phinney's Blog: Testing Zend Framework MVC Applications
by Chris Cornutt July 01, 2008 @ 12:05:32
Matthew Weier O'Phinney has posted about a project he undertook to make it simple to test "userland projects" built with the Zend Framework as easy to test as the framework's own Front Controller and Dispatcher.
One of my ongoing projects the past few months has been to create an infrastructure for functional testing of ZF projects using PHPUnit. This past weekend, I made the final commits that make this functionality feature complete.
This new functionality allows you to create stub test case classes, use a Zend_Dom_Query object with CSS selectors/XPath for queries and makes available a special PHPUnit test case that handles the interface between some of the custom functionality (boostrapping, dispatching requests, etc) and PHPUnit.
He includes a sample test case that has assertions for calls to a controller with an action, that a page contains a login form and that a page creates a session and redirects to a profile page.
You can get this functionality from the incubator on the subversion repository for the project.
voice your opinion now!
testing zendframework application phpunit testcase
Sebastian Bergmann's Blog: Global Variables and PHPUnit
by Chris Cornutt June 17, 2008 @ 08:49:19
Sebastian Bergmann has a new post today about a feature of the PHPUnit unit testing tool that has the possibility of breaking when objects are introduced - backing up the globals.
It is hard to test code that uses singletons. The same is true for code that uses global variables. Typically, the code you want to test is coupled strongly with a global variable and you cannot control its creation. An additional problem is the fact that one test's change to a global variable might break another test.
You can disable the backup option if you'd like by setting the $backupGlobals option in your test to false. This lets PHPUnit know that you want to leave the globals (and superglobals) alone during the run.
voice your opinion now!
global variable phpunit unittest backup global superglobal test disable
Ken Guest's Blog: Book review PHP Objects, Patterns and Practice (second edition)
by Chris Cornutt June 04, 2008 @ 07:58:39
Ken Guest has posted a review of yet another PHP-related book from APress publishing, "PHP Objects, Patterns and Practice (Second Edition)".
While being an easy read, this is a well written, serious book and is aimed squarely at enterprise-level developers and software engineers who make their living through the development and architecture of solutions developed in PHP.
He breaks down the book into the three sections its title mentions - working with objects, design patterns and a healthy dose of PEAR, phpDocumentor, PHPUnit, CVS and phing.
voice your opinion now!
book review apress object pattern pear phpdocumentor cvs phpunit phing
|
Community Events
Don't see your event here? Let us know!
|