1) You test db should be empty. The framework will automatically
create/drop the tables for each test.
2) You don't need to call "loadFixtures" at the start of each test.
3) I don't think you need to App::import your model if you use
ClassRegistry::init. Not 100% on that, and it shouldn't hurt even if
you do.
4) In my fixtures I have the line:
var $import = array('table' => 'name', 'records' => false);
I had to use the actually table name to get everything working with
ClassRegistry setting the right database. It didn't work if I just
specified the model.
Hope that helps.
-Matt
http://www.pseudocoder.com
On Nov 25, 4:29 pm, pragna <a...@andyjordan.com> wrote:
> I've been struggling for a couple of days now to build a very simple
> 'model' unit test.
>
> CakePHPs "Convention over Configuration" should help me out here and
> so should the Cookbook.
>
> With Unit Tests though, it's quite hard to uncover the what the
> conventions are. The filename conventions described in the Cookbook
> (1.2) differ from, for example, the fixture files created using Bake.
> Also the guys at Debuggable have re-factored and simplified the
> building of model tests as well as sharing a fixturize script that
> automates the building of fixtures.
>
> All great stuff!
> If only I could get the simplest test up and running :(
>
> My failing code is here:http://oneyeareatingcake.blogspot.com/2008/11/cakephp-unit-test-model...
>
> It is the most basic of Unit Tests on a simple findAll function in the
> most basic of models. The reason this is not working has to be that
> I'm breaking the convention somewhere. Maybe in file naming or in the
> way I'm including the fixture?
>
> I'd be very grateful if someone could get me out of this mess by
> pointing out what I've got wrong.
> Thanks,
> Andy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment