On 24 Lut, 11:39, Nico <ngev...@gmail.com> wrote:
> Greetings
>
> I've run into something strange while testing my 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 article unit test, 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 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