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.

0 Comments

No comments yet.

Leave a Reply