I don't do mocks I do inheritance. I inherit from the test model and
overwrite the $useDbConfig var.
I followed the manual (book.cakephp.org). Before cake I was doing
rails and in there you dont need to do anything special for testing.
You just define the test database and when the tests run they are
automatically using the test database and they recreate the tables and
populate it with fixture data every time you run them. Tnx for your
suggestions it sounds really nice and logical. I will try to implement
it in my project.
On Jun 11, 2:22 am, Grant Cox <[EMAIL PROTECTED]> wrote:
> 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
-~----------~----~----~----~------~----~------~--~---