[Catalyst] Reference to the connected Model::DBIC schema for testing?

Jonathan Rockway jon at jrock.us
Wed Oct 11 01:15:02 CEST 2006


> 1) Is there any way to get a reference to the connected Model::DBIC
> schema from an external script (e.g. using Test::WWW::Mechanize::Catalyst)?
>
> 2) Is it a totally insane idea to try?

Hopefully someone else has a better way, but I just instantiate the Model 
class myself (with a fake $c, courtesy of Test::MockObject) and use that.  I 
use this technique to simulate a user with Mech (or 
Test::WWW::Catalyst::Selenium), and then check to make sure my data store 
gets updated properly.

You mock object just needs to set $c->config to return a hashref of config, 
and you should be all set to:

$model 
and then use $model as though it were returned by $c->model('Whatever').

Regards,
Jonathan Rockway

-- 
package JAPH;use Catalyst qw/-Debug/;($;=JAPH)->config(name => do {
$,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //,
";$;"]->[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;->setup;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: not available
Url : http://lists.rawmode.org/pipermail/catalyst/attachments/20061010/0490f8c6/attachment.pgp 


More information about the Catalyst mailing list