Do You have fixtures defined? AFAIR I had similar problem, when no
fixtures loaded. Try creating fixtures with
var $import("model"=>"ModelName", "records"=> false);
var $records = array();For each model that is used in tests... On 25 Lut, 15:07, WebRenovator <[email protected]> wrote: > ok.... here it is > > class DATABASE_CONFIG { > > var $default = array( > 'driver' => 'mysqli', > 'persistent' => false, > 'host' => 'localhost', > 'login' => 'boost', > 'password' => 'boost', > 'database' => 'boost', > 'prefix' => '', > ); > > var $test = array( > 'driver' => 'mysqli', > 'persistent' => false, > 'host' => 'localhost', > 'login' => 'apptest', > 'password' => 'apptest', > 'database' => 'apptest', > 'prefix' => 'boost_', > );} > > ?> > > for what its worth, it works the other way around .. ie if i write to > the db in the test it picks it up in the code... but just not the > other way round (as defined above) > > On Feb 25, 3:24 pm, Grzegorz Pawlik <[email protected]> wrote: > > > Please post contents of Your app/config/database.php file... > > > On 24 Lut, 11:39, Nico <[email protected]> wrote: > > > > Greetings > > > > I've run into something strange whiletestingmy models. Here's a > > > scenaro (names have been changed for simplicity). I have 2 models, > > > Article and Comment. in the article model i have code as such: > > > > function myAction() { > > > $this->Comment->save($data)} > > > > now, I'm wanting to test this as part of my articleunittest, so i've > > > got something similar to > > > > $this->assertTrue(count($this->Article->Comment->find('all')) > 0); > > > > The test returns an empty false (since no records have been written to > > > the database), but when running the application as normal, it works. > > > My theory is that the Article model isn't writing data to the Comment > > > database table during the test since the Comment model hasn't been > > > initialized. I've tried including the Comment model in the article > > > test (as an import) as well as doing this in the startTest function > > > > function startTest() { > > > $this->Article =& ClassRegistry::init('Article'); > > > $this->Article->Comment =& ClassRegistry::init('Comment'); > > > > } > > > > Still no luck. Has anybody had this experience before? What am I doing > > > wrong? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
