[Catalyst] Unit Testing

Matt S Trout dbix-class at trout.me.uk
Sun Apr 20 15:19:31 BST 2008


On Sun, Apr 20, 2008 at 10:38:46AM +0300, Octavian Rasnita wrote:
> From: "Dave Rolsky" <autarch at urth.org>
> >On Sat, 19 Apr 2008, John Romkey wrote:
> >
> >>I suspect that most Catalyst users build their applications so that the 
> >>controllers do too much work. I certainly did, and I'm gradually 
> >>rewriting mine to move most of the work into the model. Where before my 
> >>controllers
> >
> >A good way to approach a webapp is to think of the Controller as a thin 
> >shim between the the web/HTTP environment and your model.
> >Of course, the ultimate benefit is that it's the only sane way to write an 
> >application ;)
> 
> I heard this for more times, but I am usually creating my controllers using 
> a helper tool like:
> 
> perl scripts/myapp_create.pl model MyData DBIC::Schema MyData create=static 
> dbi:mysql:database=mydata user pass
> 
> Is this tool not recommended? Or should it be used only as a tool for 
> starting creating the model and the DBIC classes?

That's a -scaffold- tool. So you use that to create an initial skeleton
model, and then add your business logic methods below the md5 line so the
skeleton parts can be regenerated.

You should always be adding more code to your DBIC schema than you're adding
to your controllers; if you find it's the other way round, you're doing it
wrong.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst mailing list