FixturesShell for CakePHP
The FixturesShell for CakePHP is a neat console application allowing you to populate and reset your applications database with all existing fixtures stored in /app/test/fixtures.
Download
You can download the source code of the FixturesShell for CakePHP here: Download 1.0 (Latest)
Installation
Place the file from above in /vendors/shell/fixtures.php. That's it - you are done : ).
Usage
Pick any table in your database and create a fixture for it. An example for a UserFixture placed inside /app/tests/fixtures/user_fixture.php can be seen below.
- class UserFixture extends CakeTestFixture {
- var $name = 'User';
- 'id' => '4810a53f-5c28-4775-8ad9-a5cb4dddecbf',
- 'email' => 'felix@debuggable.com',
- 'password' => '3984890d90s9dasad9as',
- 'level' => 'admin',
- ),
- 'id' => '4810a53f-ba4c-49b9-b2e8-a5cb4dddecbf',
- 'email' => 'tim@debuggable.com',
- 'password' => '3984890d90s9dasad9ae',
- 'level' => 'admin',
- ),
- );
- }
To dump all tables that you have fixtures for and re-populate them with the values inside your fixtures run this from within /cake/console:
$ ./cake fixtures
And you should get some output like this:
Welcome to CakePHP v1.2.0.6311 beta Console --------------------------------------------------------------- App : app Path: /Users/felix/dev/www/php5/scorpion/app --------------------------------------------------------------- -> Truncating table "users" -> Inserting records for "users" -> Done inserting 3 records for 1 table
The shell will pick up any fixture named *_fixture.php inside /app/tests/fixtures/ automatically.
If you are working with UUIDs instead of default auto-incrementing ones, then this might also be useful to you:
$ ./cake fixtures uuid
Which returns 10 UUIDs to use in your fixtures:
Welcome to CakePHP v1.2.0.6311 beta Console --------------------------------------------------------------- App : app Path: /Users/felix/dev/www/php5/scorpion/app --------------------------------------------------------------- 481c596e-e820-4bdb-b735-51714dddecbf 481c596e-0f94-4483-99b4-51714dddecbf 481c596e-2254-4268-947d-51714dddecbf 481c596e-3514-4f47-af37-51714dddecbf 481c596e-4770-4aea-9098-51714dddecbf 481c596e-59cc-488d-a298-51714dddecbf 481c596e-6d54-41e8-aed7-51714dddecbf 481c596e-7f4c-4798-a132-51714dddecbf 481c596e-91a8-4157-9ee6-51714dddecbf 481c596e-a4cc-4968-921f-51714dddecbf
Support & Feedback
If you have any questions or feedback regarding the FixturesShell for CakePHP, please leave a comment on our blog post: FixturesShell - Share your test data
License
The FixturesShell is licensed under the MIT license. This means you can do just about anything with it other than removing the license information. Software projects that are using this code do not need to be open source or even mention the usage of the code published here.
Unless stated otherwise, the entire code was written by Debuggable Limited.

@Ben Ramsey: I agree, and I don't think anyone has anything against well-formed markup in and of...
I believe the movement to subvert XHTML will harm the Open Data Movement, the Linking Open Data...
@Nate: Wow, I had no idea I was responsible for destroying the web. My bad.
I'm absolutely...
@Andrew Jones: I think you've got it exactly wrong, and your view is diametrically opposed to...
Arriving (very) late to this discussion. My gut assumption here is that most, if not all, of the...