I must admit I don't really get the point of using mock models in your
tests - sure it's best for your tests to be testing just the model in
question, but creating a whole swag of mock objects just creates
another layer that can have bugs in it.  I want to test my application
code - not mock code that emulates the application...

Anyway, my point is that I just test the application models directly.
The only problem with this of course is that you don't want the test
cases mucking around in your real database - so I have defined a app/
config/database.test.php with the same database connection names, just
to a test database server.  I require this in the app/webroot/test.php
(before the normal database file is loaded), and just have appropriate
"if ( !class_exists('DATABASE_CONFIG') ){" in both files - this way
the real database just isn't defined in test modes, but all the
application models are unchanged.

Maybe I should have a chat to the devs on IRC, and write this up on
Bakery if they approve.


On Jun 10, 11:56 pm, strangy <[EMAIL PROTECTED]> wrote:
> What is the preferred way of testing associations/relations in custom
> model methods?
> When testing a model I make a test model class that inherits from the
> original model class. I use $this->name in all my custom model methods
> when I need to get the model name for the conditions. Now if I use
> associations in those methods i don't know how to test them. Do I need
> to redefine the $hasMany, $hasManyAndBelongsTo & $belongsTo in my test
> model or is there another way.
>
> What do you think about it?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to