X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F97result_class.t;h=0b0db50881030e96b6891677f75fa83eea6d975b;hb=59d93f02996d7573c0d1daa6efb97d44e4132f56;hp=79211587b56320fad44035cdb95d66f0dbbbee13;hpb=b72d5dd34049102b38ad21afc6fb808a7cba9fd1;p=dbsrgits%2FDBIx-Class.git diff --git a/t/97result_class.t b/t/97result_class.t index 7921158..0b0db50 100644 --- a/t/97result_class.t +++ b/t/97result_class.t @@ -2,20 +2,39 @@ use strict; use warnings; use Test::More; +use Test::Exception; use lib qw(t/lib); use DBICTest; my $schema = DBICTest->init_schema(); -plan tests => 9; +plan tests => 12; { my $cd_rc = $schema->resultset("CD")->result_class; + throws_ok { + $schema->resultset("Artist") + ->search_rs({}, {result_class => "IWillExplode"}) + } qr/Can't locate IWillExplode/, 'nonexistant result_class exception'; + +# to make ensure_class_loaded happy, dies on inflate + eval 'package IWillExplode; sub dummy {}'; + my $artist_rs = $schema->resultset("Artist") ->search_rs({}, {result_class => "IWillExplode"}); is($artist_rs->result_class, 'IWillExplode', 'Correct artist result_class'); - + + throws_ok { + $artist_rs->result_class('mtfnpy') + } qr/Can't locate mtfnpy/, + 'nonexistant result_access exception (from accessor)'; + + throws_ok { + $artist_rs->first + } qr/Can't locate object method "inflate_result" via package "IWillExplode"/, + 'IWillExplode explodes on inflate'; + my $cd_rs = $artist_rs->related_resultset('cds'); is($cd_rs->result_class, $cd_rc, 'Correct cd result_class');