I'm just getting started with the testing infrastructure in CakePHP
1.2.    It was a little rough getting started, because few people
seemed to be able to point me to any sort of canonical documentation,
but thanks to 
http://cakebaker.42dh.com/2007/03/23/how-to-use-the-official-cakephp-test-suite/
and 
http://bakery.cakephp.org/articles/view/testing-models-with-cakephp-1-2-test-suite
I'm getting up to speed now.   Also this recent thread:
http://groups.google.com/group/cake-php/browse_thread/thread/b4e784c39cf87a4f/b117c946daf3554b
will be helpful when I start testing controllers.

(To the powers that be: Is there any way these articles could be
featured more prominently, say as part of some sort of testing portal
page on cakephp.org?   I've had problems with the search there so I'm
not sure I would have found the bakery article if it weren't linked on
CakeBaker.   I really lament that there's no longer an official wiki.)

When I baked a few models I also requested tests even though I didn't
know what I was doing.  I got, for example, a GameTestCase class that
I'm trying to build out now.

Two questions:

== Should it pass? ==
My baked test file included the following commented method:

        function testMe() {
                $result = $this->TestObject->findAll();
                $expected = 1;
                $this->assertEqual($result, $expected);
        }

Of course this fails because findAll() returns a nested array, not an
integer.   Is this supposed to pass? Did something change in the
return type of findAll()?    Or was it merely intended that the user
would replace the expected 1 with something more substantial?


== Necessary to subclass the model under test? ==

The Bakery article above makes a point of deriving a model from the
model under test:


class ArticleTest extends Article {
    var $name = 'ArticleTest';
    var $useDbConfig = 'test_suite';
}


It also names the fixture ArticleTest.   Is this an essential step to
use fixtures?    Because bake did some of the other "plumbing"
mentioned in that article (e.g. loadModel), it made me wonder whether
I need to add another class or not.   I was able to add the fixture so
it didn't appear to break my test, but perhaps I'm setting myself up
wrong for the future.




Forgive my curiosity if these questions are just nitpicking -- I try
to err on the side of asking too many questions, because they say
there may be other curious people who just haven't gotten around to
asking. ;-)

Regards,

Philip
http://www.bulldogs.com/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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