debuggable

 
Contact Us
 

Fixturize Shell - Generate your fixtures automatically

Posted on 5/9/08 by Felix Geisendörfer

Hey folks,

this is post #17 of my 30 day challenge.

When you start writing unit tests or using the fixtures shell we published a while back you might be quite annoyed about something. The fact that typing in all those fixture data is not really efficient. In order to make our lives a little easier, we came up with a shell that takes any database table of yours, and creates the PHP fixture code for you automatically.

You can download the: Fixturize Shell at the Debuggable Scraps repository. Further documentation can be found in the git repositories readme file as always.

Usage is a simple as this:

cd cake/console
./cake fixturize posts

This will create a file called app/tests/fixtures/post_fixture.php for you that holds all of your posts tables records. Additional documentation can be found in the github readme.textile file as always.

If you have any questions or want to comment, feedback is welcome!

-- Felix Geisendörfer aka the_undefined

 
&nsbp;

You can skip to the end and add a comment.

daniel said on Sep 05, 2008:

hello, I like the idea very much! it's something probably everyone missed but somehow nobody has come with this handy solution before you.

thx! regards
danielz

Aybar Dumlu said on Sep 06, 2008:

thank you very much ;)
_________________________

http://www.aybardumlu.com

kabturek said on Sep 06, 2008:

felix, i was suppose to write something like this for a few days (even talked about it on #cakephp)... ande i look at the rss reader and such a pleasent suprise awaits me!
thanks mate!

more testsuite tips! ;)

Tarique Sani said on Sep 08, 2008:

Now that is one very useful piece of code - I will be using it a lot - Thanks

primeminister said on Oct 08, 2008:

Nice Felix! But I have a table with 10.000 records. I don't need all 10.000 for a good testcase. And I can't set the lmit to a number. I already did in the scipt, but would be nice to give it as an argument on the commandline.
Cheers!

Jason  said on Oct 10, 2008:

Great tool. I just finished modifying it to output the schema and limit the amount of records. Felix: It should be in your inbox.

Abba Bryant  said on Jan 13, 2009:

Any chance for adding callback support to the original fixtures shell? A beforeSave callback would allow us to hash passwords etc from the fixture instead of by hand..

You guys would be my heros.

alan blount said on May 26, 2009:

I'm trying this (for the first time) with [CakePHP version: 1.2.3.8166]

I'm getting the following error:

Error: Class FixtureizeShell could not be loaded

This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.