[Catalyst] getting $c in model unit test
Matt S Trout
dbix-class at trout.me.uk
Thu May 17 21:56:54 GMT 2007
On Thu, May 17, 2007 at 05:42:03PM +0100, Matt Lawrence wrote:
> Matt S Trout wrote:
> > On Wed, May 16, 2007 at 10:11:56AM +0100, Matt Lawrence wrote:
> >
> >> Ah yes. You don't normally forward to a Model. If you're testing a
> >> controller (or, I suppose, a view), it's best to forward, otherwise you
> >> get a similar error if the controller method you're calling forwards to
> >> another method itself.
> >>
> >
> > Maybe that means there's a case for adding a context($uri) export to C::Test
> >
> >
>
> I suppose that would come in useful in some situations, but the question
> is how much stuff would get done before the context gets returned. You
> could stop before you call the action, having called the relevant begin
> and auto methods, but then what could you usefully test other than the
> action itself?
Erm. I was more thinking returning it after a prepare but with ->req populated.
The idea for me would be for unit testing controllers/views (and any model code
that uses ACCEPT_CONTEXT).
Of course, if you wanted you could then call ->dispatch and then ->finalize
yourself, but once you're getting as far as that you're probably better using
the standard stuff (plus replacing the view with a mock one via
$c->_components->{MyApp::View::Foo} = $test_view to handle testing just the
controller ops and stash contents)
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director Want a managed development or deployment platform?
Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/
More information about the Catalyst
mailing list