zen of coding

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:
http://api.cakephp.org/tests/

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.

  • Seems like the best advice I´ve read in CakePHP world. Ever.

  • teknoid

    @Martin Bavio

    Now, now… c’mon ;)

  • My, My… All ministers in a room. I didn’t know it was searchable!

    Thank you very much Teknoid! I will see if there is a space available in my party… ;)

  • teknoid

    @primeminister

    ;)

  • Ron Richey

    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…

  • @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.

%d bloggers like this: