Test Fixtures for CakePHP Has-and-Belongs-to-Many Relationships | End Point Blog

Nice entry on how to get HABTM tests to work in CakePHP 1.2.

Test Fixtures for CakePHP Has-and-Belongs-to-Many Relationships

CakePHP, a popular MVC framework in/for PHP, offers a pretty easy-to-use object-relational mapper, as well as fairly straightforward fixture class for test data. Consequently, it’s fairly easy to get into test-driven development with CakePHP, though this can take some acclimation if you’re coming from Rails or Django or some such; the need to go through a web interface to navigate to and execute your test cases feels, to me, a little unnatural. Nevertheless, you can get writing tests pretty quickly, and the openness of the testing framework means that it won’t get in your way. Indeed, compared to the overwhelming plethora of testing options one gets in the Ruby space — and the accompanying sense that the choice of testing framework is akin to one’s choice of religion, political party, or top 10 desert island album list — CakePHP’s straightforward testing feels a little liberating.

Which is why it was a little surprising to me that getting a test fixture going for the join table on a has-and-belongs-to-many (HABTM) association is — at least in my experience — not the clearest thing in the world.

via Test Fixtures for CakePHP Has-and-Belongs-to-Many Relationships | End Point Blog.

This entry was posted on Tuesday, November 24th, 2009 at 2:44 am and is filed under cakePHP. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply