What can we learn from CakePHP tests?

Update: Currently the API for test cases searches is down (but coming back soon).
Remember, that you still have the test cases in the core of cake, so you can and should utilize them all the time ;)
(If anyone wishes to volunteer their time to help out to bring test case search online, please contact Gwoo or Mark Story)

First things first, all current CakePHP test cases are now searchable here:

If you ever find yourself stuck wondering how to use some feature in CakePHP look to the test cases to provide a helpful hint.

Let’s consider an example.

I don’t know how to use SQL’s BETWEEN syntax in cake… let’s see if there are any matches for “between” in the test cases.

Search at the above link, and a few results, but here’s one: DboSourceTest::testArrayConditionsParsing
Hmm… conditions parsing? Sounds about right…
And looky-looky what we’ve got there.
All sorts of examples including the BETWEEN syntax.

Hopefully you can see how great it is to have the test cases available and how much you can discover and learn by digging around in the tests source code.

6 thoughts on “What can we learn from CakePHP tests?

  1. It seems that searches at the test URL http://api.cakephp.org/tests/ just return results from the API — not the nice examples you cited. I saw that you submitted a bug on this a few months back, and that it was fixed and/or closed. It would appear that it is a problem once again…

  2. @Ron Richey

    I just checked with Mark Story/Gwoo and the said that it’s just a matter of time, but the tests are coming back as part of the API.

    If anyone wishes to volunteer their time to help out, it would be greatly appreciated.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s